List of GIT Commands

List of some GIT Commands those we are used in day-to-day programming task:

  • To color the Git console in Ubuntu
git config --global color.ui auto

The color.ui is a meta configuration that includes all the various color.* configurations available with git commands. This is explained in-depth in git help config.

color.ui: This variable determines the default value for variables such as color.diff and color.grep that control the use of color per command family. Its scope will expand as more commands learn configuration to set a default for the –color option. Set it to always if you want all output not intended for machine consumption to use color, to true or auto if you want such output to use color when written to the terminal, or to false or never if you prefer git commands not to use color unless enabled explicitly with some other configuration or the –color option.

  • To get diff in file
git diff
  • To keep password in memory
git config --global credential.helper cache

which tells git to keep your password cached in memory for (by default) 15 mins

git config --global credential.helper "cache --timeout=3600"

which tells git to keep your password cached in memory for 3600 seconds

  • To add new file on Git
git add
git commit -m "new file added"
  • To increase Git performance
git gc

will give significant speed on your local repository.
Basically, git-gc : it is for cleanup unnecessary files and optimize the local repository.

  • To get logs of specific file
git log "file-name"
  • To get file from Git of specific version
git show commit-no:file-name
  • To know file list from Git of specific version
git show commit-no --name-only
  • To remove file/folder from GIT
git rm file-name
# if you want to remove folder, then
git rm folder-name -r

git commit -m "your message"
git push origin master
  • To change message after GIT commit
git commit --amend -m "New commit message"
  • To create the Tag in GIT 
git tag -a V2 -m "tag 2"
git push origin V2
git checkout tag-name
# List of tags
git tag
  • To cloning the branch from tag
git clone --branch tag_name repo_url
  • To get the checkout from the Tag
git checkout tags/tag-name

  • 23
    Shares