Skip to content

Commit 3e8af33

Browse files
author
jordanmccullough
committed
Add line break for easier non Markdown-rendered reviewing
1 parent 48fef4e commit 3e8af33

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

downloads/github-git-cheat-sheet.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,75 +19,113 @@ http://git-scm.com
1919
## Configure tooling
2020
Configure user information for all local repositories
2121

22+
2223
```$ git config --global user.name "[name]"```
24+
2325
Sets the name you want attached to your commit transactions
2426

27+
2528
```$ git config --global user.email "[email address]"```
29+
2630
Sets the email you want attached to your commit transactions
2731

32+
2833
```$ git config --global color.ui auto```
34+
2935
Enables helpful colorization of command line output
3036

3137

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

41+
3542
```$ git init [project-name]```
43+
3644
Creates a new local repository with the specified name
3745

46+
3847
```$ git clone [url]```
48+
3949
Downloads a project and its entire version history
4050

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

54+
4455
```$ git status```
56+
4557
Lists all new or modified files to be committed
4658

59+
4760
```$ git diff```
61+
4862
Shows file differences not yet staged
4963

64+
5065
```$ git add [file]```
66+
5167
Snapshots the file in preparation for versioning
5268

69+
5370
```$ git diff --staged```
71+
5472
Shows file differences between staging and the last file version
5573

74+
5675
```$ git reset [file]```
76+
5777
Unstages the file, but preserve its contents
5878

79+
5980
```$ git commit -m"[descriptive message]"```
81+
6082
Records file snapshots permanently in version history
6183

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

87+
6588
```$ git branch```
89+
6690
Lists all local branches in the current repository
6791

92+
6893
```$ git branch [branch-name]```
94+
6995
Creates a new branch
7096

97+
7198
```$ git checkout [branch-name]```
99+
72100
Switches to the specified branch and update working directory
73101

102+
74103
```$ git merge [branch-name]```
104+
75105
Combines the specified branch’s history into the current branch
76106

107+
77108
```$ git branch -d [branch-name]```
109+
78110
Deletes the specified branch
79111

80112

81113
## Refactor filenames
82114
Relocates and remove versioned files
83115

116+
84117
```$ git rm [file]```
118+
85119
Deletes the file from the working directory and stage the deletion
86120

121+
87122
```$ git rm --cached [file]```
123+
88124
Removes from version control but preserve the file locally
89125

126+
90127
```$ git mv [file-original] [file-renamed]```
128+
91129
Changes the filename and prepare it for commit
92130

93131
## Supress tracking
@@ -98,63 +136,94 @@ Excludes temporary files and paths
98136
build/
99137
temp-*
100138
```
139+
101140
A text file named `.gitignore` suppresses accidental versioning of files and paths matching the specified patterns
102141

142+
103143
```$ git ls-files --other --ignored --exclude-standard```
144+
104145
Lists all ignored files in this project
105146

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

150+
109151
```$ git stash```
152+
110153
Temporarily stores all modified tracked files
111154

155+
112156
```$ git stash pop```
157+
113158
Restores the most recently stashed files
114159

160+
115161
```$ git stash list```
162+
116163
Lists all stashed changesets
117164

165+
118166
```$ git stash drop```
167+
119168
Discards the most recently stashed changeset
120169

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

173+
124174
```$ git log```
175+
125176
Lists version history for the current branch
126177

178+
127179
```$ git log --follow [file]```
180+
128181
Lists version history for a file, including renames
129182

183+
130184
```$ git diff [first-branch]...[second-branch]```
185+
131186
Shows content differences between two branches
132187

188+
133189
```$ git show [commit]```
190+
134191
Outputs metadata and content changes of the specified commit
135192

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

196+
139197
```$ git reset [commit]```
198+
140199
Undoes all commits after [commit], preserving changes locally
141200

201+
142202
```$ git reset --hard [commit]```
203+
143204
Discards all history and changes back to the specified commit
144205

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

209+
148210
```$ git fetch [bookmark]```
211+
149212
Downloads all history from the repository bookmark
150213

214+
151215
```$ git merge [bookmark]/[branch]```
216+
152217
Combines bookmark’s branch into into current local branch
153218

219+
154220
```$ git push [alias] [branch]```
221+
155222
Uploads all local branch commits to GitHub
156223

224+
157225
```$ git pull```
226+
158227
Synchronizes bookmark history and incorporate current branch changes
159228

160229
---

0 commit comments

Comments
 (0)