I have the following alias:
unpushed== !GIT_CURRENT_BRANCH=$(git name-rev --name-only HEAD) &&
git log origin/$GIT_CURRENT_BRANCH..$GIT_CURRENT_BRANCH --oneline
when I execute this with |wc -l
, it tells me that I have 394 unpushed commits.
I use this number to run git diff somecommitid HEAD~394
.
This fails with the following error:
fatal: ambiguous argument 'HEAD~394': unknown revision or path not in the working tree.
Strangely, it works right up until the number 358. In another clone, I have 478 commits, and git commands including git show
work up until HEAD~411 and then fail. Any clues? I am using git 1.7.5.2 on debian linux.
The best explanation I can think of is that the ~
operator doesn't follow branches. It only includes the first parents. If you want to refer to the last pushed commit, just use origin/$GIT_CURRENT_BRANCH
.