2

I saw a lot of very nice git graphs like in this post: Pretty git branch graphs

But there was never the branch name, in which the commit was done. How can I add this?

clemens
  • 69
  • 6
  • 3
    Branches are just pointers to commits, not the other way around. I don't think that information is kept in git. – pishpish Aug 04 '20 at 08:28
  • Does this answer your question? [Finding what branch a Git commit came from](https://stackoverflow.com/questions/2706797/finding-what-branch-a-git-commit-came-from) – mkrieger1 Aug 04 '20 at 08:29
  • Yes and no. I would love if the branch name is listed in the graphical solution as well. – clemens Aug 04 '20 at 09:13
  • The branch in shown in the link provided by you. – fdan Aug 04 '20 at 09:25
  • 1
    What if commit `abcdef` was created on `branch1` and, after several commits, you create `branch2` and delete `branch1`? Please, read carefully what @pishpish wrote. – Enlico Aug 04 '20 at 09:26

1 Answers1

1

The --decorate flag adds branch names to git log. For example, without:

$ git log --oneline --graph
* 51ebf55b93 The sixth batch for 2.26
*   f97741f6e9 Merge branch 'es/outside-repo-errmsg-hints'
|\
| * e0020b2f82 prefix_path: show gitdir when arg is outside repo
* |   123538444f Merge branch 'jk/doc-credential-helper'
|\ \
| * | cc4f2eb828 doc: move credential helper info into gitcredentials(7)

With --decorate:

$ git log --oneline --graph --decorate
* 51ebf55b93 (HEAD -> master, origin/master, origin/HEAD) The sixth batch for 2.26
*   f97741f6e9 Merge branch 'es/outside-repo-errmsg-hints'
|\
| * e0020b2f82 (es/outside-repo-errmsg-hints) prefix_path: show gitdir when arg is outside repo
* |   123538444f Merge branch 'jk/doc-credential-helper'
|\ \
| * | cc4f2eb828 (jk/doc-credential-helper) doc: move credential helper info into gitcredentials(7)
AtnNn
  • 5,686
  • 1
  • 23
  • 29