Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display git log --graph --decorate with HEAD on top

Tags:

git

git-log

With this command:

git log --all -n30 --graph --abbrev-commit --decorate \
   --date=relative --format=format:'%h - (%ar) %s - %an%d'

I will get a wonderful tree which is exactly what I am looking for except that the HEAD is not always on the top.

If I remove the --all option, I will also lose all the displayed branches.

How can I keep both the HEAD on top and still see the full tree visible up to the last 30 elements?

In other words what I get is

   * d4b7d5a - (foo)
   * * 44f53e2 - (HEAD)
   |/
   * 4587f32 - (bar)

And What I want to get is:

   * 44f53e2 - (HEAD)  <- HEAD on the top
   | * d4b7d5a - (foo)
   |/
   * 4587f32 - (bar)
like image 406
nowox Avatar asked May 11 '15 12:05

nowox


People also ask

What does head -> Master mean in git log?

These 3 items mean the following: HEAD -> master - Your current, local working copy of the repository is at this point and on the master branch. origin/master - Your remote master branch is also at this point. my-new-branch - Your local my-new-branch branch is also at this point.

What does -- Decorate do in git log?

The --decorate flag makes git log display all of the references (e.g., branches, tags, etc) that point to each commit.

What does -- Oneline do in git?

Git Log Oneline The oneline option is used to display the output as one commit per line. It also shows the output in brief like the first seven characters of the commit SHA and the commit message.


1 Answers

Unfortunately I dont believe it is possible, since d4b7d5a(foo) commit was made after your HEAD. You could reverse the order of your log but thats not the point. The only way I know to leave HEAD always on top would be something like the option '--before' to display only the commits made before HEAD.

You can find more about --before and others filters here: https://www.atlassian.com/git/tutorials/git-log

Any way, you can find a similar question here: Git log --graph; HEAD to top

But there is no solution there either.

like image 94
Marcone Avatar answered Sep 28 '22 08:09

Marcone