Show Menu
Cheatography

GIT Cheat Sheet Cheat Sheet (DRAFT) by

Git Cheat Sheet

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

Author

Jan Wojewoda

Git

Git Init

$ git init
- transform the current directory into a Git repository
$ git init [direc­tory]
- create an empty Git repository in the specified directory

Git Clone

$ git clone [repo]
- clone the repository located at [repo] onto the local machine
$ git clone [repo] [direc­tory]
- clone the repository located at [repo] into the folder called [direc­tory] on the local machine
======­===­===­===­===­===­======
[repo]:
/path/­to/­rep­o.git/
file:/­//p­ath­/to­/re­po.git/
ssh://­[us­er@­]ho­st.x­z[­:po­rt]­/pa­th/­to/­rep­o.git/
http[s­]:/­/ho­st.x­z[­:po­rt]­/pa­th/­to/­rep­o.git/
ftp[s]­://­hos­t.x­z[:­por­t]/­pat­h/t­o/r­epo.git/
rsync:­//h­ost.xz­/pa­th/­to/­rep­o.git/

Git Config

$ git config user.name [name]
- define the author [name] to be used for all commits in the current repository
$ git config --global user.name [name]
- write to global ~/.git­config file rather than the repository .git/c­onfig
$ git config --global user.email [email]
- define the author email to be used for all commits by the current user
$ git config --global alias.[­al­ias­-name]
- create a shortcut for a Git command
$ git config -system core.e­ditor [editor]
- define the text editor used by commands like
git commit

$ git config --global --edit
- open the global config­uration file in a text editor for manual editing
======­===­===­===­===­===­======
Git stores config­uration options in three separate files, which lets you scope options to individual reposi­tories, users, or the entire system:

* [repo]­/.g­it/­config – reposi­tor­y-s­pecific settings
* ~/.git­config – user-s­pecific settings. This is where options set with the --global flag are stored
* $(pref­ix)­/et­c/g­itc­onfig – system­-wide settings

Git Add

$ git add [file]
- stage all changes in for the next commit
$ git add [direc­tory]
- stage all changes in for the next commit
$ git add -p [file]
- begin an intera­ctive staging session that lets you choose portions of a file to add to the next commit