Skip to content

Commit b353916

Browse files
author
Jordan McCullough
committed
Merge pull request #69 from github/cheat-sheet-v1.1.1
Cheat sheet grammar and punctuation update
2 parents 125a94e + 3fb4633 commit b353916

File tree

1 file changed

+141
-72
lines changed

1 file changed

+141
-72
lines changed

downloads/github-git-cheat-sheet.md

Lines changed: 141 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# GitHub Git Cheat Sheet
22

3-
Git is the open source distributed version control system that facilitates GitHub activities on your laptop or desktop. This cheat sheet summarizes commonly-used Git command line instructions for quick reference.
3+
Git is the open source distributed version control system that facilitates GitHub activities on your laptop or desktop. This cheat sheet summarizes commonly used Git command line instructions for quick reference.
44

55
## Install git
6-
GitHub provides desktop clients that include a graphical user interface for the most common repository actions and an automatically updating command line edition of Git for advanced scenarios.
6+
GitHub provides desktop clients that include a graphical user interface for the most common repository actions and an automatically updating command line edition of Git for advanced scenarios.
77

88
### GitHub for Windows
99
http://windows.github.com
@@ -19,143 +19,212 @@ http://git-scm.com
1919
## Configure tooling
2020
Configure user information for all local repositories
2121

22-
```git config --global user.name "[name]"```
23-
Set the name you want attached to your commit transactions
2422

25-
```git config --global user.email "[email address]"```
26-
Set the email you want attached to your commit transactions
23+
```$ git config --global user.name "[name]"```
2724

28-
```git config --global color.ui auto```
29-
Enable helpful colorization of command line output
25+
Sets the name you want attached to your commit transactions
26+
27+
28+
```$ git config --global user.email "[email address]"```
29+
30+
Sets the email you want attached to your commit transactions
31+
32+
33+
```$ git config --global color.ui auto```
34+
35+
Enables helpful colorization of command line output
3036

3137

3238
## Create repositories
3339
Start a new repository or obtain one from an existing URL
3440

35-
```git init [project-name]```
36-
Create a new local repository with the specified name
3741

38-
```git clone [url]```
39-
Download a project and its entire version history
42+
```$ git init [project-name]```
43+
44+
Creates a new local repository with the specified name
45+
46+
47+
```$ git clone [url]```
48+
49+
Downloads a project and its entire version history
4050

4151
## Make changes
4252
Review edits and craft a commit transaction
4353

44-
```git status```
45-
List all new or modified files to be committed
4654

47-
```git diff```
48-
Show file differences not yet staged
55+
```$ git status```
56+
57+
Lists all new or modified files to be committed
58+
59+
60+
```$ git diff```
61+
62+
Shows file differences not yet staged
63+
64+
65+
```$ git add [file]```
66+
67+
Snapshots the file in preparation for versioning
68+
4969

50-
```git add [file]```
51-
Snapshot the file in preparation for versioning
70+
```$ git diff --staged```
5271

53-
```git diff --staged```
54-
Show file differences between staging and the last file version
72+
Shows file differences between staging and the last file version
5573

56-
```git reset [file]```
57-
Unstage the file, but preserve its contents
5874

59-
```git commit -m"[descriptive message]"```
60-
Record file snapshots permanently in version history
75+
```$ git reset [file]```
76+
77+
Unstages the file, but preserves its contents
78+
79+
80+
```$ git commit -m"[descriptive message]"```
81+
82+
Records file snapshots permanently in version history
6183

6284
## Group changes
6385
Name a series of commits and combine completed efforts
6486

65-
```git branch```
66-
List all local branches in the current repository
6787

68-
```git branch [branch-name]```
69-
Create a new branch
88+
```$ git branch```
89+
90+
Lists all local branches in the current repository
91+
92+
93+
```$ git branch [branch-name]```
94+
95+
Creates a new branch
96+
7097

71-
```git checkout [branch-name]```
72-
Switch to the specified branch and update working directory
98+
```$ git checkout [branch-name]```
7399

74-
```git merge [branch-name]```
75-
Combine the specified branch’s history into the current branch
100+
Switches to the specified branch and updates working directory
76101

77-
```git branch -d [branch-name]```
78-
Delete the specified branch
79102

103+
```$ git merge [branch-name]```
80104

81-
## Refactor filenames
105+
Combines the specified branch’s history into the current branch
106+
107+
108+
```$ git branch -d [branch-name]```
109+
110+
Deletes the specified branch
111+
112+
113+
## Refactor file names
82114
Relocate and remove versioned files
83115

84-
```git rm [file]```
85-
Delete the file from the working directory and stage the deletion
86116

87-
```git rm --cached [file]```
88-
Remove from version control but preserve the file locally
117+
```$ git rm [file]```
118+
119+
Deletes the file from the working directory and stages the deletion
120+
121+
122+
```$ git rm --cached [file]```
89123

90-
```git mv [file-original] [file-renamed]```
91-
Change the filename and prepare it for commit
124+
Removes from version control but preserves the file locally
92125

93-
## Supress tracking
126+
127+
```$ git mv [file-original] [file-renamed]```
128+
129+
Changes the file name and prepare it for commit
130+
131+
## Suppress tracking
94132
Exclude temporary files and paths
95133

96134
```
97135
*.log
98136
build/
99137
temp-*
100138
```
139+
101140
A text file named `.gitignore` suppresses accidental versioning of files and paths matching the specified patterns
102141

103-
```git ls-files --other --ignored --exclude-standard```
104-
List all ignored files in this project
142+
143+
```$ git ls-files --other --ignored --exclude-standard```
144+
145+
Lists all ignored files in this project
105146

106147
## Save fragments
107148
Shelve and restore incomplete changes
108149

109-
```git stash```
110-
Temporarily store all modified tracked files
111150

112-
```git stash pop```
113-
Restore the most recently stashed files
151+
```$ git stash```
152+
153+
Temporarily stores all modified tracked files
154+
155+
156+
```$ git stash pop```
114157

115-
```git stash list```
116-
List all stashed changesets
158+
Restores the most recent stashed files
117159

118-
```git stash drop```
119-
Discard the most recently stashed changeset
160+
161+
```$ git stash list```
162+
163+
Lists all stashed changesets
164+
165+
166+
```$ git stash drop```
167+
168+
Discards the most recently stashed changeset
120169

121170
## Review history
122171
Browse and inspect the evolution of project files
123172

124-
```git log```
125-
List version history for the current branch
126173

127-
```git log --follow [file]```
128-
List version history for a file, including renames
174+
```$ git log```
175+
176+
Lists version history for the current branch
177+
178+
179+
```$ git log --follow [file]```
129180

130-
```git diff [first-branch]...[second-branch]```
131-
Show content differences between two branches
181+
Lists version history for a file, including renames
132182

133-
```git show [commit]```
134-
Output metadata and content changes of the specified commit
183+
184+
```$ git diff [first-branch]...[second-branch]```
185+
186+
Shows content differences between two branches
187+
188+
189+
```$ git show [commit]```
190+
191+
Outputs metadata and content changes of the specified commit
135192

136193
## Redo commits
137194
Erase mistakes and craft replacement history
138195

139-
```git reset [commit]```
140-
Undo all commits after [commit], preserving changes locally
141196

142-
```git reset --hard [commit]```
143-
Discard all history and changes back to the specified commit
197+
```$ git reset [commit]```
198+
199+
Undoes all commits after [commit], preserving changes locally
200+
201+
202+
```$ git reset --hard [commit]```
203+
204+
Discards all history and changes back to the specified commit
144205

145206
## Synchronize changes
146207
Register a repository bookmark and exchange version history
147208

148-
```git fetch [bookmark]```
149-
Download all history from the repository bookmark
150209

151-
```git merge [bookmark]/[branch]```
152-
Combine bookmark’s branch into into current local branch
210+
```$ git fetch [bookmark]```
211+
212+
Downloads all history from the repository bookmark
213+
214+
215+
```$ git merge [bookmark]/[branch]```
216+
217+
Combines bookmark’s branch into current local branch
218+
219+
220+
```$ git push [alias] [branch]```
221+
222+
Uploads all local branch commits to GitHub
223+
153224

154-
```git push [alias] [branch]```
155-
Upload all local branch commits to GitHub
225+
```$ git pull```
156226

157-
```git pull```
158-
Synchronize bookmark history and incorporate current branch changes
227+
Synchronizes bookmark history and incorporates current branch changes
159228

160229
---
161230

0 commit comments

Comments
 (0)