- Create a base folder for all of your commands
mkdir my-git-custom-commands
- Create file name with git-commandName . In this tutorial we will be creating the following files:
touch git-lazyrebase
touch git-remote-diff
touch git-lazypush
touch git-lazyrebase-push-force
touch git-lazyammend-push-force
touch git-lazycheckout
- Make each file executable
chmod +x git-lazyrebase
chmod +x git-remote-diff
chmod +x git-lazypush
chmod +x git-lazyrebase-push-force
chmod +x git-lazyammend-push-force
chmod +x git-lazycheckout
- Add your commands directory to PATH
export PATH=$PATH:/your-directory/my-git-custom-commands
- Refresh your terminal
source ~/.zshrc
- Save configuration on terminal startup
nano ~/.zshrc
and put this command in it
export PATH=$PATH:/your-directory/my-git-custom-commands
- Make aliases to run them with ease
git config --global alias.r 'lazyrebase'
git config --global alias.ll 'log --oneline'
git config --global alias.rd 'remote-diff'
git config --global alias.p 'lazypush'
git config --global alias.rpf 'lazyrebase-push-force'
git config --global alias.apf 'lazyammend-push-force'
git config --global alias.c 'lazycheckout'
# Rebase to latest changes in develop branch
git r develop
# Shows log with one line
git ll
# Shows diff between remote branch and local
git rd
# Commit and push changes to remote
git p "commit message"
# Rebase to provided branch followed by force push current branch
git rpf develop
# Add latest changes to last commit and force push it
git apf
# Save local directory, checks branch and pull changes from remote to local
git c develop