Git log placeholder for branch

--pretty=format it have any placeholder to display the name of the branch that is --pretty=format for git --pretty=format (in git log and git show)?

How is %H for a commit hash?

+6
source share
3 answers

Entries are not in branches, but in branches - these are just repo-local labels hanging on a particular commit. For example, most projects have only one root, and each individual branch returns to this. Git does not care that if any branch is your “main” branch, it is entirely a matter of interpretation.

You can

 git branch --contains $thatcommit 

to see all the branches that can track the pedigree for this commit, and

 git log --branches --decorate --simplify-by-decoration --oneline \ --ancestry-path --first-parent ^$thatcommit 

to see all branches that trace the pedigree with this message through their primary links (i.e. not branches that include this, just a merge).

edit: it’s really easy to say “branches”, but it’s very difficult for beginners to remember that every name you use in Git is tracked in a very short order for an otherwise-undifferentiated object in the db object - refname is just a convenient finger in the repo. More pedantically correct would be a “branch branch” or even “fixing the tip of a branch”.

The only thing related to the ref fiction is the full spelling of "refs / heads / $ branchname", and when git checkout sees that it makes HEAD symbolic link to this - so everyone who updates HEAD instead updates the branch hint, and each who looks at HEAD sees the current tip of the branch.

You can put repo-local notes on refs links; for a few convenient commands, see the branch.$branchname config branch.$branchname for your default values.

+1
source

Add the git log --decorate and display branches, tags, etc.

  • If you want to register to display a graph, you can also add --graph
  • If you are using uxin based OS, you can use this .githelpers

From the magazine documentation:

- decorate [= short | full | no]

Print the link names of any displayed transactions. If short is specified, the ref refs / heads /, refs / tags / and refs / remotes / prefixes will not be printed. If full is specified, the full name of the link (including the prefix) will be printed. The default setting is short.

The output of the .githelprs script:

enter image description here

+8
source

Use the --source flag.

From the documentation:

- a source

Print the link name indicated on the command line by which each commit was reached.

0
source

Source: https://habr.com/ru/post/988368/


All Articles