Git: aliases and hooks
Git aliases
Open ~/.gitconfig
with your favorite text editor.
And paste the following config.
They are basically shortcuts for the common git commands.
git history
: It shows last month’s commits for the current user, or as my one of my friends call it git toggl.git undo
: Who doesn’t screw up a commit? wrong files, wrong message, endless possibilities…
Git hooks
Hooks are programs you can place in a hooks directory to trigger actions at certain points in git’s execution. - docs |
Make a new directory in home to store them.
Download a pre-commit file. It contains a scrap of code which won’t let you commit files with debuggers. It works for Ruby/Ruby on Rails projects by scanning each line for debuggers. It will let you know if you forgot something.
Tell git where to find your hooks:
Now every time call to git commit
will be checked against those patterns.
If you want to commit your changes anyway, use git commit --no-verify
to bypass the pre-commit and commit-msg hooks.
You can also add a .gitignore
file to be used globally.