The Git operations can be intensive for various reasons, for example,
- to deliver quality code, it is suggested to review our working directory before making a commit
- the team runs code review and therefore need to frequently modify previous commits
- need to review own commits because the code review feedback for one of our commits actually affects the others
- distracted by other tasks and hence forget what we have made to the codebases
- need to search for the commits of similar features as a reference for the new feature development, to help avoid mistakenly missing something in our implementation
- too many unknowns with the huge and complex codebases and may need to use stash to temporarily store the code changes made during the PoC or trial-and-error
- ...
Therefore, I have written this script to set up my Git aliases. Yet, this is quite complicated, but the aliases follow certin patterns to help you memorize them and once you get used to them, your productivity will be significantly improved.
- clone the project
git clone https://github.com/8ooo8/my-git-aliases/
- modify set-git-config.sh
- ensure it correctly points to your Bash or Zsh
#!/bin/zsh
- check the shell currently in use if needed
echo $SHELL
- check the shell currently in use if needed
- write down your username, email, favourite editor and pager
myGitUserName='8ooo8' myGitUserEmail='ben.cky.workspace@gmail.com' myEditor='nvim' myPager='less' myGerritRemote='origin'
- add your own aliases or/and configuration, possibly specific for your company, e.g. set the git hooks
# [company's specific need, e.g. set git hooks] # your own aliases or/and configuration for your company
- ensure it correctly points to your Bash or Zsh
- set execution right for set-git-config.sh
chmod +x set-git-config.sh
- run set-git-config.sh
./set-git-config.sh
Please note that this script does not only contain my aliases but also my basic Git config.
- zsh 5.8 (x86_64-apple-darwin21.0), git version 2.32.0
- Git Bash (mintty 3.5.2 (x86_64-pec-msys) [Windows 19043]), git version 2.34.1.windows.1