Appstechy

13416123_5243854

Useful Git Cheat Sheet

Useful Git Cheat Sheet

Configure name that is identifiable for credit when reviewing version history
# git config –global user.name “<FIRST AND LAST NAME>”

Configure email that will be associated with each history marker
# git config –global user.email “EMAIL-ADDRESS”

Set automatic command line coloring for Git – for easy reviewing
# git config –global color.ui auto

Initializing an existing directly as Git repository or create a new local repo
# git init

Clone existing repo from hosted location on local machine via URL
# git clone <REPO-URL>

Clone specific branch from hosted location
#git clone -b <branch-name> <REPO-URL> <FOLDER_NAME>

Show modified files in working directory (staged for next commit)
# git status

Add a file to your next commit
# git add <FILE>

Add all changes/files to commit
# git add.

Add some changes/file to commit
# git add -p <file>

Check difference of what is changed (but not staged)
# git diff

Check difference of what is staged (but not committed)
# git diff –staged

Commit all local changes or staged content as a new commit snapshot
# git commit –m “<your comment>”

Check current branch name
# git branch

Check all branches
# git branch –av

Create a new branch at the current commit
# git branch <branch-name>

Delete a local branch
# git branch –d <branch-name>

Create and switch to a new branch
# git checkout -b <branch-name>

Merge specified branch history into current
# git merge <branch-name>

Check all commits history in the current active branch
# git log

Check log for any file
# git log –p <file>Show all commits on “branch-prod” that are not on “branch-dev”
# git log <branch-dev>..<branch-prod>

Show difference of what is on “branch-prod” that are not on “branch-dev”
# git diff <branch-dev>..<branch-prod>

Check all configured remotes
# git remote –v

Check info about any remote repo
# git remote show <remote-repo>

Fetch and merge any commits from remote branch
# git pull <remote-repo> <branch-name>

Push your local branch commits to remote branch
# git push origin <branch-name>

Push/upload local changes to remote branch
# git push <remote-repo> <branch-name>

Push/upload local changes to remote branch
# git push <remote-repo> <branch-name>

Push/upload local changes to remote branch
# git push <remote-repo> <branch-name>

Delete the file from the project and stage removal from the commit
# git rm <FILE>

Apply any commits of a current branch ahead of specified
# git rebase <branch-name>

Revert a commit
# git revert <commit>

Un-stage a file while retaining changes in the working directory
# git reset <FILE>

Save modified and staged changes
# git stash

List stack order of stashed file changes
# git stash list

Leave a Comment

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

Scroll to Top

Chipper is here to help you

Contact_Us