Skip to content

MKhasib/Automate-repetitive-tasks

Repository files navigation

Automate repetitive tasks with custom Git commands

Installation

  1. Create a base folder for all of your commands
mkdir my-git-custom-commands
  1. 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
  1. 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
  1. Add your commands directory to PATH
export PATH=$PATH:/your-directory/my-git-custom-commands
  1. Refresh your terminal
source ~/.zshrc
  1. Save configuration on terminal startup
nano ~/.zshrc

and put this command in it

export PATH=$PATH:/your-directory/my-git-custom-commands
  1. 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'

Running

# 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

About

Automate repetitive tasks with custom Git commands

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages