Skip to content

Instantly share code, notes, and snippets.

@amrynsky
Last active January 25, 2024 23:27
Show Gist options
  • Save amrynsky/56229ffb56cc3eb38be7a9346de9cf2c to your computer and use it in GitHub Desktop.
Save amrynsky/56229ffb56cc3eb38be7a9346de9cf2c to your computer and use it in GitHub Desktop.
git aliases
`git config --global --edit`
```
[alias]
# Command shortcuts
ci = commit
co = checkout
st = status
# Display tree-like log, because default log is a pain…
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit
# Rebase current branch from master
sync = !git checkout main && git pull && git checkout - && git rebase main
# Useful when you have to update your last commit
# with staged files without editing the commit message.
oops = commit --amend --no-edit
# Ensure that force-pushing won't lose someone else's work (only mine).
push-with-lease = push --force-with-lease
# Rebase won't trigger hooks on each "replayed" commit.
# This is an ugly hack that will replay each commit during rebase with the
# standard `commit` command which will trigger hooks.
rebase-with-hooks = rebase -x 'git reset --soft HEAD~1 && git commit -C HEAD@{1}'
# List local commits that were not pushed to remote repository
review-local = "!git lg @{push}.."
# Edit last commit message
reword = commit --amend
# Undo last commit but keep changed files in stage
uncommit = reset --soft HEAD~1
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment