0

Just wondering if there's a way to recover them after they've been deleted. I'm assuming here that I've deleted it both locally and remotely.

cjm2671
  • 18,348
  • 31
  • 102
  • 161
  • branch is a lightweight pointer to a commit in Git. So you can always create a branch pointing the exact commit again. – rogue-one Mar 07 '14 at 16:53

3 Answers3

3

You can use git reflog to find the SHA1 of the last commit of the branch. From that point, you can recreate a branch using

git branch branchName <sha1>

source: Git undo local branch delete

Community
  • 1
  • 1
Lajos Veres
  • 13,595
  • 7
  • 43
  • 56
1

branch is a lightweight pointer to a commit in Git. So you can always create a branch pointing the exact commit again using the command again.

git branch branchname <sha1-of-commit>
rogue-one
  • 11,259
  • 7
  • 53
  • 75
0

As others have explained, you can use the SHA-1 value. It is a good idea to tag the branch before deleting that way it is removed from the branch list but you keep information about the branch and can use the tag to recover it. Also you can enter a message explaining that it was removed and the reason.

M0eB
  • 151
  • 2
  • 3