Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Is there a quick way to see when was the last time that git merge master was done on the current working branch?

I'm usually working on a branch that is diverged from master. So while I'm developing things, I perform git merge master once in a while. And sometimes I wanna know when was the last time, I did git merge master on that branch. I know I can do git log and look for "Merge branch 'master'", and see the Date of the commit… but if there is a magic, I'd like to know!

like image 730
beatak Avatar asked Nov 16 '11 20:11

beatak


2 Answers

git show :/"Merge branch 'master'"
like image 163
twaggs Avatar answered Sep 27 '22 21:09

twaggs


I personally like to inspect the difference in revision trees:

git log --graph --left-right --cherry-pick --oneline branch1...branch2

Also, in the 'magic' department there is

git show-branch 
git show-branch branch1 branch2
git show-branch --all # which does all of the above and more

And finally,

git merge-base branch1 branch2

to name the base revision that would be merged from


Notes:

  • replace branch1 and branch2 as appropriate for your project
  • you can alias those commands if you like them: http://progit.org/book/ch2-7.html#git_aliases
  • the --cherry-pick options carries a rare kind of magic:
--cherry-pick 

Omit any commit that introduces the same change as another commit on the "other side" when the set of commits are limited with symmetric difference.

For example, if you have two branches, A and B, a usual way to list all commits on only one side of them is with --left-right, like the example above in the description of that option. It however shows the commits that were cherry-picked from the other branch (for example, "3rd on b" may be cherry-picked from branch A). With this option, such pairs of commits are excluded from the output.

like image 23
sehe Avatar answered Sep 27 '22 19:09

sehe