General form of commands

Git <git-options> <commands> <command-options> <operands>

Telling git who you are & Global settings

git config --global user.name "Senthil Palanivelu”
git config --global user.email [email protected]
git config --global core.editor vim
git config --global core.autocrlf input
git config --global help.format web
git config --global diff.tool vimdiff
git config --global merge.tool vimdiff
git config --global difftool.prompt false
Git config —-global merge.conflictstyle diff3

Check global configuration settings in user home directory

cat ~/.gitconfig or git config —-global —-list

Creating alias for long commands

git config <scope option> alias.<name> <command string>
git config --global alias.hist 'log --pretty=format:"%h ( %ad %an ) %s %d" --graph —-date=short —-name-only’
git config --global alias.globallist 'config --global --list'

Staging scope, Moving files from working directory to staging area

git add . # ( stage all files that are new or changed )

Moving files from staging area to local repository

git commit -m "new file added” or git commit -m “message” *.py

Stage and commit the file with the shortcut

git commit -am "comment string” # Note, it doesn’t pick up newly created files

Diff Utility

git diff                          # diff the version in the working area against the version on the staging area
git diff —-staged                 # diff the version in the staging area against the version in the local repository
git diff HEAD                     # diff the version in the working area against the version in the local rep bypassing staging area
git diff HEAD:file1.txt file1.txt # compare the local repository current version against the version in the working directory
git difftool --tool-help

Log

git log
git blame file1.txt              # see the revisions that last modified each line
git log —-patch
git log -1                       # most recent commit
git log --oneline
git log --oneline —name-only     # list of files changed with each commit along with the change information
git log —-author=“senthilcaesar" # filter log output by author

Branch

git branch testing
git branch -d testing
git checkout testing
git branch --list
git checkout -b testing # Git ensures that the content in your working directory is consistent with whatever branch you switch to