1.

How do you recover a deleted un-merged branch in your project source code?

Answer»

By default, git does not allow you to delete a branch whose work has not yet been MERGED into the main branch.

 To see the list of branches not merged with the CHECKED out branch run:

Divya1@Divya:initialRepo [master] $git branch --no-merged  DEV

 --If you TRY to delete this branch, git displays a warning:

Divya1@Divya:initialRepo [master] $git branch -d dev error: The branch 'dev' is not fully merged. If you are sure you want to delete it, run 'git branch -D dev'.

--If it is still deleted using the -D flag as:

Divya1@Divya:initialRepo [master] $git branch -D dev

--See the references log information

Divya1@Divya:initialRepo [master] $git reflog cb9da2b (HEAD -> master) HEAD@{0}: checkout: MOVING from dev to master b834dc2 (origin/master, origin/dev) HEAD@{1}: checkout: moving from master to dev cb9da2b (HEAD -> master) HEAD@{2}: checkout: moving from master to master cb9da2b (HEAD -> master) HEAD@{3}: checkout: moving from dev to master b834dc2 (origin/master, origin/dev) HEAD@{4}: checkout: moving from master to dev cb9da2b (HEAD -> master) HEAD@{5}: checkout: moving from uat to master 03224ed (uat) HEAD@{6}: checkout: moving from dev to uat

b834dc2 is the commit id when we jumped to ‘dev’ branch
Create a branch named ‘dev’ from this commit id again.

Divya1@Divya:initialRepo [master] $git checkout -b dev b834dc2 Switched to a new branch 'dev' Divya1@Divya:initialRepo [dev]


Discussion

No Comment Found