Configs Git

Git aliases, explained

All of these go in ~/.gitconfig under [alias] — no reload needed, git reads it on every invocation. Or add them without opening an editor: git config --global alias.last 'log -1 HEAD --stat' and so on.

git last: show the commit you just made

What did I just commit? The one command you want at 6pm on a Friday, when "what exactly did I push" matters. Shows the latest commit with its diffstat.

[alias]
    last = log -1 HEAD --stat

WHERE: ~/.gitconfig under [alias] — no reload needed.

git lg: a compact graph of every branch

A compact, decorated, graph view of all branches. Once you’ve used this, the plain log feels like reading a novel with all the chapters shuffled. Add -15 or whatever count you like if the full graph is too much.

[alias]
    lg = log --graph --oneline --decorate --all

WHERE: ~/.gitconfig under [alias] — no reload needed.

git stash-all: stash untracked files too

Plain git stash leaves untracked files sitting in your worktree, which quietly defeats the point when the thing you’re hiding is a new file. This stashes everything, tracked and untracked.

[alias]
    stash-all = stash push --include-untracked

WHERE: ~/.gitconfig under [alias] — no reload needed.

git undo: take back the last commit

Committed too early, forgot a file, wrong message? This rolls the last commit back into staged changes — nothing is lost, you just get another shot at it. If the commit was already pushed, everyone else’s history breaks; use it locally.

[alias]
    undo = reset --soft HEAD~1

WHERE: ~/.gitconfig under [alias] — no reload needed.