How can I say when this message went to the thread?

I am trying to find the origin of the error in our code base. I have a SHA commit, which I suspect caused a breakdown, but I also know the date when the error appeared. I want to check when this commit was merged into our main branch.

Is there an easy way to do this?

+4
source share
4 answers

git bisect should help you find the error pretty well.

https://www.kernel.org/pub/software/scm/git/docs/git-bisect.html

http://git-scm.com/book/en/Git-Tools-Debugging-with-Git#Binary-Search

As for the SHA commit you are aiming for, just run git log on it and it will tell you everything about commit (date, author, etc.). Run git log -p on it to see what changes have made.

+5
source
 git branch --contains SHA1 

should print all branches that contain the given commit.

+2
source

You can find the suspicious commit based on the date with:

 git log --before=<date> -n 1 

This, or something with a date a day or two earlier, might be a "good" starting point for your git bisect .

+1
source

I assume that your main branch is master and that the suspicious SHA is in $SHA .

First find the merge commits that are in master , but not in the $SHA history:

 $ git log --merges --oneline $SHA..master 

Then check each of these commits to determine which one contains $SHA . Suppose this merge commit id is in $MERGE . You can list all the commits that have been merged into master using this commit with git log --oneline $MERGE^..$MERGE .

(This works because $MERGE^ is the [first] parent of $MERGE , that is, a master snapshot before merging, so $MERGE^..$MERGE lists commits in $MERGE , but not in $MERGE^ , i.e. commit to $MERGE , but not to master before merging.)

Then you can grep for your $SHA target:

 $ git log --oneline $MERGE^..$MERGE | grep ^$SHA 

The first merge that gets any of its results for the last grep is your winner. Once you have determined the commit, you can git show for more information.

 $ git show $MERGE 

I would be wondering how to do this if anyone knows about this.

+1
source

Source: https://habr.com/ru/post/1483203/


All Articles