user2362874
user2362874

Reputation: 131

Shorten the refs when using: git log --graph --pretty=oneline --decorate=full --oneline

I'm using

git log --graph --pretty=oneline --decorate=full --oneline

to get the following commit graph:

* 221b95b (HEAD, refs/remotes/origin/master, refs/remotes/origin/HEAD, refs/remotes/upstream/master, refs/heads/master) Formatting commit

but showing the full refs path is inconvenient as it is too long. is there a way to shorten it to get the paths shorten as follows?:

* 221b95b (HEAD, origin/master, origin/HEAD, upstream/master, master) Formatting commit

Upvotes: 0

Views: 379

Answers (2)

Gabriele Petronella
Gabriele Petronella

Reputation: 108159

Use --decorate (which defaults to short) instead of --decorated=full.

Also --pretty=oneline is redundant since you're already used --oneline, which is a shorthand for --pretty=oneline --abbrev-commit.

Ultimately, just do

git log --graph --decorate --oneline

Result:

* 73017eb (HEAD, origin/master, master) A commit message

Upvotes: 1

user456814
user456814

Reputation:

Just use --decorate instead of --decorate=full, since short is the default value of --decorate, as stated in the git log documentation (bold emphasis mine):

--decorate[=short|full|no]

Print out the ref names of any commits that are shown. If short is specified, the ref name prefixes refs/heads/, refs/tags/ and refs/remotes/ will not be printed. If full is specified, the full ref name (including prefix) will be printed. The default option is short.

Also, as jthill commented, --pretty=oneline is redundant, since --oneline already lists commits on one line each:

--oneline means --pretty=oneline --abbrev-commit.

So putting it all together:

git log --graph --decorate --oneline

Upvotes: 0

Related Questions