Skip to content

Instantly share code, notes, and snippets.

@AndroPlus
Created May 23, 2018 08:19
Show Gist options
  • Save AndroPlus/bbd6dc7154634e77c404f47635196d53 to your computer and use it in GitHub Desktop.
Save AndroPlus/bbd6dc7154634e77c404f47635196d53 to your computer and use it in GitHub Desktop.
Git clone into an existing directory
Git clone into an existing directory
Here am explaining how to clone a remote git repo to an existing folder (assume this folder has some untracked files).
Go to the existing folder in terminal
Run $git init
Run $git remote add origin <your git repo url>
Run $git fetch
Run $git checkout -t origin/master (This works better for an empty directory, wont suit for a non-empty directory)
Run $git reset origin/master if you have some files in your local existing directory.
View the current repo status $git status
Stage your file for commit $git add -f *.*
Commit your files $git commit -m “message”
Push your changes $git push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment