Git Utilities and hacks

Although GIT is an old topic, still i am adding a collection of basic and useful git utilities and hacks that is helpful in day-to-day git cli interaction.

Reference to learn git command and usage

Setting up default credential

to setup the credential, we can create a .git-credentials file user home directory


these will be used during remote operation

Setup alias to the git command

to setup the alias, we can create a .gitconfig file at the git project

  co = checkout
  ci = commit
  st = status
  br = branch
  hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
  type = cat-file -t
  dump = cat-file -p

after setting this up, you can execute the command line

>>> git hist # instead of git log that will show a formatted output

You can also define some other config as well

	name = chandra
	email = chandra
	spellcheck = false
	helper = store
	filemode = false

you can define this under user home directory to be effective at all or project wise as well

Ignoring some file [Project wise]

You can create a .gitignore file at root of the project to ignore some of the files from being part of the repo

# Node artifact files

# Compiled Java class files

Git repo options at local [project-wise]


you can edit the file that is available under your local git repo at the path



You can also write shell script that can be called during git command interaction and you can put them under .git/hooks

like , execute some command before commit or after commit

There are already sample available, you can rename them

Leave a Reply

Your email address will not be published. Required fields are marked *