I am able to see a commit using 'git show 9a6fe03'
But when I use 'git log' and search for '9a6fe03', I see nothing.
And when I do 'git grep 9a6fe03', it returns nothing too.
Can you please tell me why?
Thank you.
Update : I find my commit when I use $git branch --all --contains 9a6fe03
git branch --all --contains 956ae03
remotes/my-git/branch1
remotes/my-git/branch2
remotes/my-git/branch3
but I don't see anything when I do
git branch --contain 9a6fe03
I get nothing.
My question is which branch I am on now? When I do '
$ git branch
* (no branch)
I think I am on a stage called 'Detached head' but when when I do 'repo sync', I get commits from other people?
Multiple questions, multiple answers. :)
1. log vs. show vs. grep
git show 9a6fe03
will show you that single commit. (Including the changes.) git log 9a6fe03
will show you also that commit and all of its ancestors. git log
(without any arguments) will show you the current commit (HEAD) and all of its ancestors. If HEAD is not an ancestor of your commit it will therefore not be shown.
git grep
is completely different. It looks at your files for a given text. As probably no files will contain the string "9a6fe03", you will get no output.
2. What branch is the commit on
There are also two different kind of branches: local branches and remote branches. - git branch
will only show local branches - git branch -r
will only show remote branches - git branch -a
will show both local and remote branches
In your case that commit is only contained in remote branches. Therefore you will only see it when specifying -r
or -a
(= --all
).
3. What branch am I on
As you are currently at "no branch" (aka detached HEAD), so you are formally on, well, no branch. ;)
You might currently see any (possibly quite old) version of your code, or even happen to be on a commit corresponding to the HEAD of a branch.
You can try git log --decorate --graph
- That will show any kinds of refs (like branche, tags, etc) next to your commits if there are any.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.