1001Ferramentas
🌳 Dev

Git Aliases Generator

Useful git aliases (st, co, br, lg, undo, save, wip, amend, hist) ready to paste into .gitconfig.

The Git shortcuts worth memorising

The alias section of a gitconfig swaps long commands for two or three letters. The gain is not typing less — it is making a command cheap that you would otherwise avoid because it is long. The clear case is the graph log: nobody types log with four options every time, but everybody types lg.

Tick the shortcuts you want and the page assembles the block ready to paste into the config file. The selection covers the ones appearing in almost every shared setup: compact status, checkout, branch, the graph log with all refs, undoing the last commit while keeping the changes, stashing, a work-in-progress commit and amending the previous commit without opening an editor.

It pays to understand each one before adopting it. The undo here is a soft reset, which drops the commit and leaves everything staged — nothing is lost. The amend rewrites the previous commit, which is safe on what has not been pushed and troublesome on what has, because it changes the hash and forces a push with overwrite. The global file lives at ~/.gitconfig; to apply it to one repository only, the same block goes in .git/config.

Frequently asked questions

Can an alias call something that is not a Git command?
It can: start the value with an exclamation mark and Git runs the rest in the shell. That is how you build shortcuts combining commands or calling a script. The catch is that the command runs from the repository root, not from the directory you are in.
Can I override an existing command?
No. Git ignores an alias named after a built-in command — creating one called status changes nothing, and it does not even warn you. If the intent is changing default behaviour, the route is a shell function with that name, not a Git alias.
How do I see the aliases I already have?
With git config --get-regexp alias, which lists everything configured, including what came from system or repository config. Worth running before adding the ones here, so you do not overwrite a shortcut you already used with another meaning.

Related Tools