I have commit number. I would like to get previous commit number(parent). I need commits from current branch.
If trying to get all parents and using revision parameter syntax, you may try using log
subcommand with
--no-walk
option.
An example, if we have the following:
$ git --oneline --graph
* A
|\
| * B
| * C
| * D
* | E
In this example, I'll use ^@
to get all parents and the --no-walk
option to
show only the parents and not their ancestors.
$ git log --no-walk A^@
commit B
........
commit E
........
Check out git rev-parse for more detail about revision parameter.