one more git history poll: do you have an alias for a fancy `git log` or `git log —graph` incantation that I use to view your Git history?
also share it below if you’d like!
Discussion
one more git history poll: do you have an alias for a fancy `git log` or `git log —graph` incantation that I use to view your Git history?
also share it below if you’d like!
@b0rk I have `git lg` for `log --oneline --graph --all`: https://github.com/lucaswerkmeister/home/blob/746b487820bf2da4bae1eeee5564544a5120172a/.gitconfig#L5
I never set up a second alias, if I want anything else I’ll just type out the options (the tab completion helps ^^)
@b0rk I have `glog` aliased to `git log --oneline --decorate --graph`
@b0rk `log -n 16 --graph --date-order --decorate --format="%h %ad %an: %d %s" --date="format:%Y-%m-%d %H:%M"`
No color or bold, I hate that on the command line. The alias `l` above has limited length and only shows the current branch. There are variants `la` with `--all` and `ll` with `-n 9999`, and `lla` and/or `lal` (some chaos there).
@b0rk In recent time I do ctrl+r a lot, but don't define aliases
@b0rk https://github.com/DivineGod/devenv/blob/cc566faa45fd52a5e01be1cc5810f5eee11e61bb/git/helpers.sh#L13
pillar[1] is my own version of column(1) to support colours in the terminal
[1]: https://github.com/DivineGod/pillar/blob/main/README.md
@b0rk I mainly use ` lol = log --pretty=oneline --abbrev-commit --graph --decorate --all`, but I also have `llp` (log-last-pull) which is `log ORIG_HEAD..FETCH_HEAD` for changes introduced by the last pull.
@b0rk git log --graph --decorate --pretty=oneline --abbrev-commit --all
@b0rk
This is the alias section from my .gitconfig:
```
[alias]
slog = log --pretty=format:'%h - %an, %ar : %s'
ilog = log --pretty=format:'%h - %an, %ai : %s'
```
@b0rk git deploy-log, which takes a base rev and produces a 4-space indented oneline-like log. I use it to paste into commit messages when I roll forward a dependency or deploy a service from a separate repo
@b0rk I do have an alias but I use tig for the most part.
Tig is much more powerful but I just use it as a glorified log viewer where I can keybind Y to easily copy the highlighted SHA to my clipboard
@b0rk I have *four* aliases for this! (But if it gets complicated I usually use Fork.) https://github.com/geeksam/dotfiles/blob/bd8db09a956c453b7663ab89435eea9dc30cfc90/bash/aliases.bash#L31
@b0rk lg = log --graph -10 --format='%C(yellow)%h%Creset %s %Cgreen(%cr)%Creset'
@b0rk Yes, the default log is a mess and I wanted a more natural log. The alias is, of course, git ln .
It's aliased to gitlog.
.
.
.
OH. You mean what does the alias expand to? I don't know! That's why I created the alias, so I wouldn't have to remember.
.
.
.
OK, let me check.
git log --date=iso --name-status --find-renames
@b0rk my alias is
graph=log --oneline --graph --decorate --all
Mostly used to help me work out what I want to interactively rebase before pushing
@b0rk I have a "git ls" alias for this, two-line format, https://github.com/Kos/dotfiles/blob/master/.gitconfig#L15
More importantly I have `git lst` which shows `origin/HEAD..HEAD` (unmerged commits on current branch) which IMO should be the default view in git GUIs but somehow never is!
@b0rk My `slog` alias: `slog = log --pretty=format:'%Cred%h%Creset %G? %Cgreen%<(20)%an%Creset %s'`
@b0rk
one for git log --oneline like almost everybody here apparently, one for checkout to reduce on typing (from before the times of 'switch'), and one to update the date when amending:
hist = log --pretty=format:'%C(yellow)[%ad]%C(reset) %C(green)[%h]%C(reset) | %C(red)%s %C(bold red){%an}%C(reset) %C(blue)%d%C(reset)' --date=short
co = checkout
amend = "!f() { git commit --amend --date=\"$(date)\"; }; f"
@b0rk
ll = "log --oneline --pretty=format:'%C(auto)%h %as %d %s' --graph --all -30";
lla = "log --oneline --pretty=format:'%C(auto)%h %as %d %s' --graph --all";
@b0rk I have `git gr` for `git log --graph` and I `git oneline` for `git log --format=oneline`. The latter is useful for scripting when I just want to know the number of commits. I also use `--format` extensively for scripting but don't really have an alias for each case.
@b0rk I dream of a day Git have the graph command for this, with minimal options to filter/format with ease.
@batsify there was a talk about this at Git Merge this year! https://www.youtube.com/watch?v=FajJe0Q1Vf8
YouTube
@b0rk Thank you, interesting.
I have no all this problems of "too branches or commits to show".
I clone my branches with --single-branch which lock to the branch having HEAD.
Can be shown with git/config file :
fetch = +refs/heads/main:refs/remotes/origin/main
Just do : git remote set-branches origin '*'
And now, I listen on all remote branches. But I fetch selectively what I want (before, explore with git ls-remote --heads).
I have never the problem of "too commits" or "too branches".
@b0rk I used to have a `git unpushed` that was `git log @{u}..`, but that disappeared and I'm too lazy to re-add it.
@b0rk
No alias, I have that incantation on short-dial with Ctrl+R.
If I can't find it on some machine, I make sure to type it once, so I can find it in the future.
@b0rk GUI and I switch between multiple depending on which fits better for my task.
On Windows Sourcetree and Tortoise
I can't stand console for this.
@b0rk I have arranged my work environment such that the precise shape of git history is not relevant.
All branches are shallow, "big merge from distantly related branches" is simply not a thing I've had to do in several decades.
I do very distinctly recall the last time I needed this kind of thing and it was a nightmare, it took I want to say two full weeks of work days to complete the primary merge and another week of fixups afterwards.
When I did need to do it it was manual cli invocation.
@b0rk There wasn't an option for "no (I don't use fancy git log incantations)" so I chose "no (other)" and am replying just to say that I basically only use "git log" (or "git log some-branch-or-label").
@b0rk I mostly switch between plain log and `alias.lag=log --all --graph` depending on how much of a mess I’ve made.
@b0rk other: I created a pretty alias for the format and also created an alias for `log --pretty=name`.
the clear benefit is I can have the same format for both `log` and `show` commands:
https://codeberg.org/pcdevil/g#pretty-aliases
@b0rk "git lg" has been my friend for over a decade
@b0rk I use [`forgit`](https://github.com/wfxr/forgit) and picked "GUI/TUI/plugin".
It is not a full blown TUI like Lazygit but more like a "fzf-wrapper" around `git` and that is exactly what I like about it. It mostly behaves like normal `git` commands and you don't have that explicit switch between terminal and TUI which makes it integrate better in my usual workflow.
It's alias for `log` is `glo`, which I also use as fallback for systems without it: `--graph --oneline --abbrev-commit --decorate`
@b0rk No. I find the git interface sufficiently painful that I very rapidly fall back on gitk or similar.
I do, however, have such aliases for Mercurial.
@b0rk i have the following in ~/.gitconfig:
[alias]
l = log
lg = log -p
lol = log --graph --decorate --pretty=oneline --abbrev-commit
lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
log-notes = !git fetch origin refs/notes/review:refs/notes/review && git log --notes=review
tree = "log --graph --oneline --all --decorate"
@b0rk my alias used to be `git history` but now that's its own git subcommand so I'm retraining myself to `git logg`. Can't look it up exactly right now, but it's something like `--oneline --tags --decorate`, it gives me a quick overview where I am in the tree before and during a rebase. Also serves to double-check that the last commits are definitely mine when I'm about to release (which is also an alias).
@b0rk I use many of the aliases included in Oh My Zsh git plugin.
@b0rk I used to but then I left the job that had that particular package of aliases and I get into git trouble rarely enough these days that I've never gone back to figure out what that fancy alias was actually doing
I think it was ohmyzsh's glog
`git log --oneline --decorate --graph --all`
@b0rk from omz, standard I believe :
`alias glol='git log --graph --pretty='\''%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'`
@b0rk
My alias:
`graph = "log --branches --graph --abbrev-commit --decorate --format=format:'%C(yellow)%h%C(reset)\t%C(bold white)%s%C(reset) %C(dim white)- %an (%ar)%C(reset)%C(auto)%d%C(reset)'"`
git log --graph --abbrev=10 --abbrev-commit "--pretty-format=$FORMAT" "$@
($FORMAT color codes the lines and adds trailers etc. in a format that is useful to me).
Honestly, though, since lazygit and jjui, I rarely, rarely use my old aliases. They're relics of a bygone era for me.
@barries lazygit is so good
@b0rk It's not visually fancy but I have some frequently used aliases to log specific commit ranges. So I'm not sure if it responds directly to the question you're asking.
[alias]
lu = log --oneline @{u}..
lp = log --oneline @{u}@{1}..@{u}
lm = log --oneline origin/HEAD..
The first one, "log upstream" shows commits on the current branch compared to its default upstream.
The second one, "log pull/push" shows changes in the last reflog update of the current branch's default remote. After a pull or push, this shows the range of commits that the pull or push operated on.
The third one, with "origin/HEAD.." shows everything that is subsequent to the HEAD branch of origin up to the checked out commit. (HEAD is usually an alias to main, but if the repository uses some other convention this transparently follows it)
I have "-p" variants of some of those (e.g., git lup), which pass the --patch flag; and "k" (instead of l, e,g., git km) variants that invoke gitk, but the key is quickly referring to those frequently used commit ranges.
ls = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
https://codeberg.org/selfawaresoup/configurations/src/branch/main/gitconfig#L40
@b0rk alias (`alias gl='git log --oneline --decorate'`) but more often Fork.app.
@b0rk I almost exclusively use Lazygit, but this was the alias I used before:
l=log --pretty="%h %C(yellow)%an%Creset %Cblue%ar%Creset %s"
@b0rk Mine is git hist:
hist = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
@b0rk mostly just use plain `git log` but I have a couple of fancy ones that I use occasionally; those I find via command history search (ctrl-r).
@b0rk I have `git gl` aliased to `git 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' $arg`