Using Git Aliases can make you feel like you have superpowers!
It wasn’t until recently that I discovered Git Aliases, they are so handy that I seriously don’t know how I lived without them. These are two that I use every day now.
Git Add Commit Push
git config — global alias.add-commit-push '!git add -A && git commit -m "$1" && git push && git status'
Once the alias has been added you can now add, commit and push all on one line.
git add-commit-push "Add, commit, push in one line!"
Git New Branch
git config --global alias.new-branch '!git checkout -b "$1" && git add -A && git commit -m "$2" && git push -u origin "$1" && git status'
This alias adds, commits and pushes current changes to a new branch.
git new-branch "123-my-branch" "Checkout, add, commit, push!"
Checkout the Git documentation for other alias ideas. Enjoy!
Top comments (1)
Nothing super advanced, theres some fancy magic things I could get into, but these are my current git aliases:
I think I have a problem.
g-count is so useful for rebasing branches.
git rebase HEAD~$(g-count) -i
For an interactive rebase on the current branch going the number of commits you have backwards.