6 ms·
For those increasingly rare times I'm not using Magit[0], I have a "git lg" alias I found once through HN[1]: git config --global alias.lg "log --color --gra
by TeMPOraL 9y ago
For those increasingly rare times I'm not using Magit[0], I have a "git lg" alias I found once through HN[1]:
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"
I strongly recommend both.
--
[0] - https://magit.vc/ https://magit.vc/
[1] - https://coderwall.com/p/euwpig/a-better-git-log https://coderwall.com/p/euwpig/a-better-git-log
- peff 9y agoYou should probably avoid `--color`, as it turns on color unconditionally, even if output is going to a file. In older versions of Git the %C color placeholders were unconditional anyway. In modern Git, they respect the normal auto-coloring settings. You can also drop `--abbrev-commit`, since `%h` abbreviates by default (use `%H` if you want the full hash).
- dalore 9y agoFor the lazy: git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"
- garborg 9y agoWe must have started from the same source. I've since added displaying message bodies by default, but similar otherwise: 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'
- knux 9y agoYou can still add color when not piping or writing to a file with `--color=auto`. 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'"
- yes_or_gnome 9y agoThis is likely to be said, "`--color=auto` is the default setting, so it's not needed." However, it's good to include it here because some users may have changed their default configuration to disable colors. This way `git log` works as their standard workflow and `git lg` for when they need a bit of color.
- bhaavan 9y agolol, I named my alias `git lol` because it is logs in one line.
- Cthulhu_ 9y agolol, I named mine 'git l' because I type it far too often.
- OskarS 9y agoI named my custom logging command 'git ls', which is an idiotic name (that should list files or something), but I'm stuck with it now :)
- codetrotter 9y agoI use two-letter bash aliases for all my most commonly used git commands. git status git diff git diff --cached git add -A git commit -m Hello git push Is instead just st dp di aa cm Hello pu Additionally I also have le For git shortlog -s -e which I don’t use very often but often enough that having an alias for it still makes sense
- nojvek 9y agoI edited my inputrc to do a prefix search. So I just ‘git x’ where x is some letter, pressing up usually finds me what I want. 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.
- jquast 9y agoi think 'xonsh' aims to do that
- hellofunk 9y agomine is assigned to the bash alias "gl"
- 9y ago
- smoyer 9y agoMany of us at work have the following alias in our .gitconfig file: lola = log --graph --decorate --pretty=oneline --abbrev-commit --all This is similar to others posted here.
- Zardoz84 9y agoI use a light variant from it : 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"
- zeotroph 9y agoThe difference is an added --date-order: "Show no parents before all of its children are shown, but otherwise show commits in the commit timestamp order."
- TomK32 9y agoI couldn't bare those relative times. My prefered tool is `tig --all` which gives me a nice view of the repo with its branches.
- heipei 9y agoI use the following since it keeps the abbreviated hash and date of the commit in their own "columns", making it easy to skim: git log --date=short --pretty=format:"%C(124)%ad %C(24)%h %C(34)%an %C(252)%s%C(178)%d"
- twic 9y agoSince we're sharing: [pretty] 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) [alias] 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)' lg is the normal log, glg is with the graph, slg lists my stashes in the same format (i find the date really helpful), and blg does the same for branches. 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.
- sedatk 9y ago> The fact that Git contains two different but largely equivalent formatting languages is kind of emblematic of its whole design, really. tip of the iceberg.
- agumonkey 9y agoHave you tried other git UIs (IDE or not) ? I wonder if there's one that is as good as magit (my opinion is no, but that's why I ask)
- TeMPOraL 9y agogitk 7-8 years ago, Github desktop app few years later. I used version control features in Eclipse and IntelliJ for SVN, but I believe the same interface maps to Git as well. 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.
- kqr 9y ago> you're always one ! ! press away from entering a manual command Huh, I didn't know this. I'll probably live in Magit from now on.
- TeMPOraL 9y agoAlso useful: any time you find yourself wondering what did Magit just do, press $ to display raw output from git commands (lists the commands issued and their return codes, TAB expands them to full output).
- agumonkey 9y agoI don't do it that often but I felt compelled to tip magit maintainer because it's just a beautiful and important piece of my emacs life.
- TeMPOraL 9y agoMagit had a Kickstarter recently (yes, an Emacs mode on Kickstarter; I was shocked too), to raise funds for continued development. I dropped some cash there; after all, it helps me quite a lot to earn my paycheck.
- Cyranix 9y agoI haven't seen anyone share an author-filtering use case yet, so here's a lightly-edited version of my "git mine" alias: log --no-merges --date=short --author="cyranix" --stat This allows me to skim through my own recent changes. "--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".