0 votes
in Git by
How to recover a deleted branch using git reflog?

1 Answer

0 votes
by

Step 1: History logs of all the references

Get a list of all the local recorded history logs for all the references (‘master’, ‘uat’ and ‘prepod’) in this repository.History-git interview questions-Edureka

Step 2: Identify the history stamp

As you can see from the above snapshot, the highlighted commit id: e2225bb along with the HEAD pointer index:4 is the one when ‘preprod’ branch was created from the current HEAD pointer pointing to your latest work.

Step 3: Recover

If you want to recover back the ‘preprod‘ branch then use the command  ‘git checkout’ passing the HEAD pointer reference with the index id – 4. This is the pointer reference when ‘preprod’ branch was created long commit id highlighted in the output screenshot.Recover-git interview questions-Edureka

I have included the frequently asked Git interview questions. If you have more questions in your mind just type it in the comment box below and we will reply you ASAP. Before going for the interview I will suggest you to check out this Git blog series.

If you found this Git Interview Questions relevant, check out the DevOps training by Edureka, a trusted online learning company with a network of more than 250,000 satisfied learners spread across the globe. The Edureka DevOps Certification Training course helps learners gain expertise in various DevOps processes and tools such as Puppet, Jenkins, Nagios and GIT for automating multiple steps in SDLC.

1.How

can you fix a broken commit?

2. Why is it advisable to create an

additional commit rather than amending an existing commit?

Related questions

0 votes
asked Aug 16, 2020 in Git by RShastri
0 votes
asked Jan 6, 2021 in Git by GeorgeBell
...