1

I have a git branch containing slash in its name, e.g. my/branch Now when I want to see my local commits (the commits which are local only and not pushed to the remote) by running

git log origin/my/branch..HEAD

git brings the following error message:

fatal: ambiguous argument 'origin/my/branch..--HEAD': unknown revision or path not in the working tree.

Use '--' to separate paths from revisions, like this: 'git [...] -- [...]'

I don't quite understand how to use this hint by git. How can I view my local commits in this case?

superM
  • 8,605
  • 8
  • 42
  • 51

2 Answers2

1

This happens when my/branch does not exist on origin (to be precise: if your local copy does not known origin/my/branch).

Call git branch -r to see if origin/my/branch is known on your local repository. If not try get fetch origin.

If this all does not help post the result of git branch -a and git remote.

Jens
  • 570
  • 3
  • 11
  • Hi @Jens. Looks like I run into precisely this case. The remote or origin doesn't contain my branch, but is merged with master. So my guess was that git should be able to compare my branch with origin master and provide the commits which aren't on the origin. – superM Mar 20 '17 at 18:30
0

when I want to see my local commits

"local" means: not on origin (the reference to the remote repo) yet.

A simple git log (without origin) is enough

git log my/branch

For getting only the commits you don't have pushed, assuming you have branched from master:

git log $(git merge-base --fork-point master my/branch) my/branch

(that is by default the same as git log my/branch..HEAD)

For your first push:

git push -u origin my/branch
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hi @VonC. In this case I get the whole history of commits, including the one I haven't pushed yet. – superM Mar 20 '17 at 18:29
  • @superM OK. I have updated the answer to list only unpushed commits. – VonC Mar 20 '17 at 18:33
  • thanks for the update. I tried the command you suggested, but still getting all the history with git log $(git merge-base --fork-point master my/branch) my/branch – superM Mar 21 '17 at 13:44
  • @superM should work though (http://stackoverflow.com/questions/462974/what-are-the-differences-between-double-dot-and-triple-dot-in-git-com). Check first if `git merge-base --fork-point master my/branch` returns the right commit. – VonC Mar 21 '17 at 13:47