Show all the commits(it’ll show just the commit hash and the commit message): $ git log -oneline In any version of a text search: $ git grep "Hello" v2.5Ĭommit History Show all commits, starting with newest (it’ll show the hash, author information, date of commit and title of the commit): $ git log Search A text search on all files in the directory: $ git grep "Hello" $ git stash apply Remove the last set of stashed changes: $ git stash drop Īdd some changes in to the next commit: $ git add -p Ĭommit all local changes in tracked files: $ git commit -aĬommit previously staged changes: $ git commitĬommit with message: $ git commit -m 'message here'Ĭommit skipping the staging area and adding message: $ git commit -am 'message here'Ĭommit to some previous date: $ git commit -date="`date -date='n day ago'`" -am ""ĭon’t amend published commits! $ git commit -a -amendĪmend with last commit but use the previous commit log message See changes/difference of a specific file: $ git diff Īdd all current changes to the next commit: $ git add. Local Changes Changes in working directory: $ git status System-wide configuration file : /etc/gitconfigĬreate a new local repository in the current directory: $ git initĬreate a new local repository in a specific directory: $ git init User-specific configuration file : ~/.gitconfig Set global editor for commit $ git config -global core.editor viĬonfiguration Files Repository specific configuration file : /.git/config Set automatic command line coloring for Git for easy reviewing: $ git config -global color.ui auto Set an email address that will be associated with each history marker: $ git config -global user.email “” Set a name that is identifiable for credit when review version history: $ git config -global user.name “” Show system configuration: $ git config -system -list Show global configuration: $ git config -global -list Show repository configuration: $ git config -local -list Setup Show current configuration: $ git config -list Git cheat sheet saves you from learning all the commands by heart.