Quickref Me Git
Quickref Me Git
Git cheatsheet
This cheat sheet summarizes commonly used Git command line instructions for quick reference.
# Getting started
_ Create a Repository _ Make a change _ Configuration
Create a new local repository Show modified files in working directory, staged Set the name that will be attached to your
for your next commit commits and tags
$ git init [project name]
$ git status $ git config --global user.name "name"
Clone a repository
Stages the file, ready for commit Set an email address that will be attached to your
$ git clone git_url commits and tags
$ git add [file]
$ git config --global user.email "email"
Clone a repository into a specified directory
Stage all changed files, ready for commit
$ git clone git_url my_directory Enable some colorization of Git output
$ git add .
$ git config --global color.ui auto
$ git branch new_branch Show the diff of what is in branchA that is not in
$ git diff --staged
branchB
Delete the branch called my_branch Apply any commits of current branch ahead of $ git diff branchB...branchA
specified one
$ git branch -d my_branch
Show any object in Git in human-readable format
$ git rebase [branch]
Merge branchA into branchB
$ git show [SHA]
Fetch down all the branches from that Git remote Add a git URL as an alias Save modified and staged changes
$ git fetch [alias] $ git remote add [alias] [url] $ git stash
Merge a remote branch into your current branch to Show the names of the remote repositories you've List stack-order of stashed file changes
bring it up to date set up
$ git stash list
$ git merge [alias]/[branch] $ git remote
Fetch and merge any commits from the tracking Remove a remote repository $ git stash drop
remote branch
$ git remote rm [remote repo name]
$ git pull
Delete the file from project and stage the removal /logs/*
for commit
!logs/.gitkeep
$ git rm [file]
/# Ignore Mac system files
.DS_store
Change an existing file path and stage the move
Show all commit logs with indication of any paths # Ignore SASS config files
that moved .sass-cache
# Git Tricks
Rename branch _ Log _ Branch
1 Renamed to new_name Search change by content List all branches and their upstreams
$ git branch -m <new_name> $ git log -S'<a term in the source>' $ git branch -vv