Show Menu
Cheatography

testing Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Git Basics

$ git init
This command creates an empty Git repository
$ git config
Get and set repository or global options
$ git add
Add file contents to the index
$ git commit -m "­<me­ssa­ge>­"
Stores the current contents of the index in a new commit along with a log message from the user describing the changes.
$ git status
Displays paths that have differ­ences between the index file and the current HEAD commit
$ git log
Show commit logs
$ git diff
Show changes between commits, commit and working tree, etc

Remote

$ git remote -v
List the remotes added to current repository
$ git remote add <na­me> <ur­l>
Add a new remote

git log

$ git log -<n­umb­er>
Limit no of commits by <nu­mbe­r>
$ git log --oneline
Limit each commit to only a single line
$ git log -p
Display full diff for each commit.
$ git log --stat
List files were added or updated with the number of lines added or removed.
$ git log --auth­or=­"­<pa­tte­rn>­"
Search for commits by a particular author.
$ git log --grep­=”<­pat­ter­n>”
Search for commits with a commit message that matches <pa­tte­rn>
$ git log <si­nce­>..<­un­til>
Show commits that occur between <si­nce> and <un­til> . Args can be a commit ID, branch name, HEAD , or any other kind of revision reference.
$ git log -- <fi­le>
Only display commits that have the specified file.
$ git log --graph --decorate
--graph flag draws a text based graph of commits on left side of commit messages. --decorate adds names of branches or tags of commits shown.
 

Config­uration

$ git config --global user.name "­[na­me]­"
Sets the name you want atached to your commit transa­ctions
$ git config --global user.email "­[email addres­s]"
Sets the email you want atached to your commit transa­ctions
$ git config --global color.ui auto
Enables helpful colori­zation of command line output

Branch

$ git branch
List, create, or delete branches
$ git branch <na­me>
create copy of current checked out branch
$ git checkout <br­anc­h>
Switch branches or restore working tree files
$ git merge <br­anc­h>
Join two or more develo­pment commit­s/b­ranch together
$ git branch -D <br­anc­h>
delete a branch
$ git fetch
Download objects and refs from another repository or fetch a branch fro another reposi­tor­y(s­pec­ified in remote)
$ git push
Update remote refs along with associated objects or push a local branch to remote server
$ git pull
Fetch from and integrate with another repository or a local branch

Reposi­tories

$ git init [proje­ct-­name]
Creates a new local repository with the specified name.
$ git clone [url]
Downloads a project and its entire version history to your local server.

Redo Commits

$ git reset [commit]
Undoes all commits afer [commit], preserving changes locally.
$ git reset --hard [commit]
Discards all history and changes back to the specified commit.

Save Fragments

*$ git stash
Tempor­arily stores all modified tracked files.
$ git stash pop
Restores the most recently stashed files.
$ git stash list
Lists all stashed change­sets.
$ git stash drop
Discards the most recently stashed changeset.