Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (29.3k points)

I checked some source code into GIT with the commit message "Build 0051".

However, I can't seem to find that source code anymore - how do I extract this source from the GIT repository, using the command line?

The source code is definitely there, now its a matter of checking it out:

C:\Source>git log -g --grep="0052"

commit 77b1f718d19e5cf46e2fab8405a9a0859c9c2889

Reflog: HEAD@{10} (unknown <Mike@.(none)>)

Reflog message: commit: 20110819 - 1724 - GL: Intermediate version. File version:  v0.5.0 build 0052.

Author: unknown <yesh@.(none)>

Date:  TueJul16 17:24:51 2019 +0100

    20110819 - 1724 - GL: Intermediate version. File version: v0.5.0 build 0052.

C:\Source>

1 Answer

0 votes
by (50.2k points)

If you have lost the history of the commit, look for the ‘build 0051’ in the commits listed by reflog using:

git reflog

Then you need to set your head to the commit where ‘build 0051’ is not visible.

Then to recover commits from reflog do:

git checkout <commit_id> 

# alternative, using reflog (see git-ready link provided)

# git checkout HEAD@{10} git checkout -b build_0051

# Make a new branch with the build_0051 as the tip

This will help you to push to github.

For further reference: https://git-scm.com/docs/git-reflog

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...