Git ahead

Almost since I started using git I found myself following the tip 'don't git pull, use git fetch and git merge'. I have found this tip useful specially to prevent unexpected disruptive changes to come to my local branch.

I used to fetch changes and take a look at incoming commits with the command:

git log <current branch>..origin/<current branch>

In my work environment, our git repo has grown quite a bit and the names of the branches have started to get longer and longer. Besides, I thought there should be a way to not have to tell git the name of the current branch, since it already knows its name. So I included this alias in my git configuration.

git config --global alias.ahead '!git log HEAD..$(git rev-parse --abbrev-ref --symbolic-full-name @{u})'

So now I can simply write git ahead after fetching from remote to get the log of incoming commits for the current branch I'm working on.

No comments:

Post a Comment