git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
 - https://magit.vc/
 - https://coderwall.com/p/euwpig/a-better-git-log
You can also drop `--abbrev-commit`, since `%h` abbreviates by default (use `%H` if you want the full hash).
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"
lg = log --graph --date=relative --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n%w(0,4,4)%-b%n%n%-N'
git config --global alias.lg "log --color=auto --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"
git log --date=short --pretty=format:"%C(124)%ad %C(24)%h %C(34)%an %C(252)%s%C(178)%d"
lg = %C(red)%h%C(reset) %C(green)%ci%C(reset) %s %C(bold blue)-- %an%C(reset)%C(yellow)%d%C(reset)
lge = %C(red)%h%C(reset) %C(green)%ci%C(reset) %s %C(bold blue)-- %an <%ae>%C(reset)%C(yellow)%d%C(reset)
reflg = %C(red)%h%C(reset) %C(green)%ci%C(reset) %s %C(bold blue)-- %an%C(reset) %C(yellow)(%gd)%C(reset)
lg = log --pretty=lg
glg = log --graph --pretty=lg
slg = stash list --pretty=reflg
blg = branch --format '%(color:red)%(objectname:short)%(color:reset) %(color:green)%(committerdate:iso)%(color:reset) %(subject) %(color:bold blue)-- %(authorname)%(color:reset) %(color:yellow)(%(refname:short))%(color:reset)'
blg can't reuse a pretty definition because it uses a completely different formatting language. The fact that Git contains two different but largely equivalent formatting languages is kind of emblematic of its whole design, really.
Like heipei, i put the fixed-width bits on the left so that they line up. I try to use consistent and distinctive colours for everything; mostly that's obvious, but yellow draws an equivalent between branch names for the normal and branch logs, and stash refs for the stashes. Including committer name for stashes is perhaps foolish consistency, although it would be useful if you do pair programming and use something like git-duet.
tip of the iceberg.
log --no-merges --date=short --author="cyranix" --stat
"--no-merges" is included in just about every log invocation I run; in a continuous integration workflow, I generally don't find merge commit info to be all that informative.
As an additional tip, the "-n <count>" form of limiting the history can be shortened to "-<count>". For example, reviewing the diff of the last two commits can be achieved with "git log -p -2".
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date-order"
"Show no parents before all of its children are shown, but otherwise show commits in the commit timestamp order."
git diff --cached
git add -A
git commit -m Hello
git shortlog -s -e
It still surprises me we don’t have good bash autocomplete.
Not sure how hard it is to create a shell but i’d do it in a heartbeat.
lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
This is similar to others posted here.
I wonder if there's one that is as good as magit (my opinion is no, but that's why I ask)
None of them even compare with Magit. They offer a small subset of Git features - unlike Magit, which gives you almost all of them, + some higher level abstractions (like "merge into"), and you're always one ! ! press away from entering a manual command. Also, the other interfaces I've used were mostly mouse based, whereas Magit just flows. Feels order of magnitude more efficient than anything else.
Huh, I didn't know this. I'll probably live in Magit from now on.
I couldn't pay on KS so I asked him his paypal handle, but it was the KS campaign that motivated me. As you said, it's a great asset to the day of developpers (or any document maintainer under git)
My prefered tool is `tig --all` which gives me a nice view of the repo with its branches.
FORMAT="%C(auto)%h %C(magenta)%ad %C(cyan)%an%C(auto)%d %s"
git config --global alias.lga "log --graph --all $PRETTY"
git config --global alias.lg "log --graph $PRETTY"
git config --global alias.la "log --all $PRETTY"
git config --global alias.ll "log $PRETTY"
git config --global alias.lf "log --pretty=fuller --stat"
• Since the --decorate option is now enabled by default (at least since Git 2.13), I don't have the --decorate option in my aliases. You may have to add them if you are using an older version of Git.
• Often while looking at the commit log, I need to know the commit date and the committer name which --oneline option does not show by default, so instead of using the --oneline option, I am formatting the one-liner logs myself with the `--pretty=format:` option to see these details.
The --simplify-by-decoration option is a nice one, something I can add to my list of aliases.
I have these aliases and a few other useful aliases documented in a bonus section named "Nifty Commands" in a fork and pull request workflow document I shared on Hacker News about a month ago. Here is the URL: https://github.com/susam/gitpr.
git clone https://github.com/ianmiell/cookbook-openshift3-frozen
git log --oneline
git log --oneline --decorate
git log --oneline --decorate --all
git log --oneline --decorate --all --graph
git log --oneline --decorate --all --graph --simplify-by-decoration
git log --oneline --decorate --all --graph --stat
git log -G 'chef-client' --graph --oneline --stat
git log -G 'chef-client' --graph --oneline --stat --pickaxe-all
When using git log, do it like "a dog"
git log --all --decorate --oneline --graph
It might have been https://stackoverflow.com/questions/1057564/pretty-git-branc... but I am not 100% sure.
git config --global alias.logadog "log --all --decorate --online --graph"
It eventually got mainlined into Mercurial as the `hg show` command:
Using this flag, my git log aliases to: `git --no-pager log --pretty=oneline -n30 --abbrev-commit`. It just shows the 30 last commits directly in my command line
One use case is : "when did branchA fork from master ?"
git log --graph --oneline --... --first-parent branchA master
git config --global alias.lg "log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all"
Screenshot of main view:
Available in most repos (ubuntu, homebrew I think, etc). Never understood why it's not more widely known than it is.
The git man pages, while thorough, don't provide anything this concise. I could easily add these commands as aliases, which I appreciate.
But it's just another tab in my GUI app (sourcetree), not a complicated set of flags that needs a blog post to explain.
The use of git as a command-line-only tool is completely strange and alien to me. It works so well as a full-fledged graphical app.
Sourcetree is an okay piece of software, but command-line git is so much faster to use. Even doing simple things like adding, committing, pulling and pushing takes half the time on the command line for me compared to Sourcetree. For this particular logging issue, you don't actually type up all those flags every time, you make an alias and it takes no time at all. If you're trying to do anything marginally complicated (say, bisecting or using the reflog), Sourcetree is all but useless.
Command line git is harder to learn and harder to use in the beginning (and virtually impossible to use unless you're comfortable with the terminal), but if you're using the terminal a significant amount anyway, it's just a better solution.
I will say: the last couple of weeks, I've been trying to get into the habit of using magit, and it's the only git client I've used that can compete with the command line. Sourcetree certainly can't, not for me.
I don't particularly like SourceTree, and it is slow and annoying in certain ways. But I'm extremely productive with it as a poweruser, and it's much better for beginners as well.
gl = log --pretty=format:\"%x1b[33m%h%x1b[36m%d %Cgreen%ae %Cred%ad%Creset%n%s%n\" --graph --date=local
git log -N (where N is 1, 2, 3, 4...)
Or, to show you what changed on each given single line, use `git log -p --color-words --`. Far more useful for long lines, IMO.
I'm also a fan of `git log -LN,N:filename`, where N is a line number. It gives you a log of that particular line number. It's like `git blame` but better.
Just click the Recyclable Commits checkbox, and all the commits from the reflog are shown in the normal SmartGit log, integrated into the view just like every other commit, with all of SmartGit's usual tools available.
Want to see which files changed in a particular commit? Click the commit.
Want to see the diff for one of those files? Click the file.
It's all right there. No copying commit hashes or having to use any other commands to see what changed.
Stashes are treated the same way. Click the Stashes checkbox and they are also displayed as part of the normal log with all tools available.
I really like the way SmartGit integrates these separate Git features into a single unified log view.
"Remember that your version might do --all by default when output goes to the terminal instead of a file"
Which version of Git does --all by default?
EDIT: Or not. It's off by default actually.
If this is indeed true, how do they achieve this? Do they modify git source code to achieve this?
 - https://launchpad.net/git
Holy un-scalable code base Batman.
You can visualize current branch or all branches.
It also has search, diffs and quite some options.
Granted, familiarity and reflex are decent reasons.
First you load mountains of code and assets. Then you have to remember which collapsed menu is hiding your target, then you go there and look around and hit it, then wait another 15s to load the next pile of crap. Can't they at least use the real estate if you have it, instead of always hiding?
I'm tired of it. None of their thrash is benefiting me.