-3

I deleted my git folder unexpectedly. i was working in remote branch repository. How can i pull my remote branch to my local?

dkinzer
  • 32,179
  • 12
  • 66
  • 85
  • What does ‘*remote branch repository*’ mean? If you deleted `.git` you can use `git init` and `git remote add`. If you deleted the whole repo, just clone again. – Biffen Feb 11 '16 at 13:40
  • Possible duplicate of [Clone all remote branches with Git?](http://stackoverflow.com/questions/67699/clone-all-remote-branches-with-git) – dkinzer Feb 11 '16 at 13:45
  • @dkinzer I think you might have misunderstood. Read the first sentence of the question again. – Biffen Feb 11 '16 at 13:46
  • @Biffen: ...hmm, it's still a duplicate imho: http://stackoverflow.com/q/651038/256854 – dkinzer Feb 11 '16 at 13:54
  • @dkinzer *Maybe* of that second one. The question is too unclear to know. – Biffen Feb 11 '16 at 13:56

4 Answers4

6

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.

dkinzer
  • 32,179
  • 12
  • 66
  • 85
0

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?

  1. Clone the repo again
  2. 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)

Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
0
git checkout -b branch_name
git pull URL branch_name
Barbz_YHOOL
  • 589
  • 4
  • 15
0
git clone -b <branch_name> <url>
rd_rscan
  • 192
  • 3
  • 15