I deleted my git folder unexpectedly. i was working in remote branch repository. How can i pull my remote branch to my local?
4 Answers
If you still have the git repo:
Just do
git fetch origin
followed by.
git checkout -b <branch> origin/<branch>
If you've deleted the git repository altogether Then reclone the repository:
git clone <repository-address>
Then, follow the steps above to get other branches if they didn't get pulled in automatically.
Comments
I deleted my git folder unexpectedly. i was working in remote branch repository. How can i pull my remote branch to my local?
What to do?
- Clone the repo again
Checkout the desired branches
# Clone the repo git clone <url> # Checkout the desired branch git checkout <branch name>
If you still have the .git folder and you did not remove it - read how to get your code back here:
How to move HEAD back to a previous location? (Detached head)
.gityou can usegit initandgit remote add. If you deleted the whole repo, just clone again.