Chandan Rajpurohit

An Artist With Technical Skills

Inspect & Compare

Examining logs,diffs and object information

show the commit history for the currently active branch

git log

show the commits on branchA that are not on branchB

git log branchB..branchA

show the commits that changed file, even across renames

git log –follow [file]

show the diff of what is in branchA that is not in branchB

git diff  branchB…branchA

show any object in Git in human-readable format

git show [SHA]

Tracking Path Changes 

Versioning file removes and path changes

delete the file from project and stage the removal for commit

git rm [file]

change an existing file path and stage the move

git mv [existing-path] [new path]

show all commit logs with indication of any paths that moved

git log –stat -M

Ignoring Patterns

Preventing unintentional staging or commiting of files

Save a file with desired patterns as .gitignore with either direct string matches or wildcard globs.


system wide ignore pattern for all local repositories

git config –global core.excludesfiles [file]

Share & Update 

Retrieving updates from another repository and updating local repos

add a git URL as an alias

git remotes add [alias] [url]

fetch down all the branches from that Git remote

git fetch [alias]

merge a remote branch into your current branch to bring it up to date

git merge [alias]/[branch]

Transmit local branch commits to the remote repository branch

git push [alias] [branch]

fetch and merge any commits from the tracking remote branch

git full

Rewrite History

Rewriting branches, updating commits and clearing history

apply any commits of current branch ahead of specified one

git rebase [branch]

clear staging area, rewrite working tree from specified commit

git reset — hard [commit]

Temporary Commits

Temporarily store modified, tracked files in order to change branches

Save modified and staged changes git stash

list stack-order of stashed file

changesgit stash list

write working from top of stash

stackgit stash pop

discard the changes from top of stash

stackgit stash drop

Leave a Reply

%d bloggers like this: