Skip to content

Commit 32356d8

Browse files
author
jordanmccullough
committed
Seed JA Cheat Sheet markdown
1 parent 0537b78 commit 32356d8

File tree

1 file changed

+235
-0
lines changed

1 file changed

+235
-0
lines changed
Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
# GitHub Git Cheat Sheet
2+
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.
4+
5+
## 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.
7+
8+
### GitHub for Windows
9+
http://windows.github.com
10+
11+
### GitHub for Mac
12+
http://mac.github.com
13+
14+
Git distributions for Linux and POSIX systems are available on the official Git SCM web site.
15+
16+
### Git for all platforms
17+
http://git-scm.com
18+
19+
## Configure tooling
20+
Configure user information for all local repositories
21+
22+
23+
```$ git config --global user.name "[name]"```
24+
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
36+
37+
38+
## Create repositories
39+
Start a new repository or obtain one from an existing URL
40+
41+
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
50+
51+
## Make changes
52+
Review edits and craft a commit transaction
53+
54+
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+
69+
70+
```$ git diff --staged```
71+
72+
Shows file differences between staging and the last file version
73+
74+
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
83+
84+
## Group changes
85+
Name a series of commits and combine completed efforts
86+
87+
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+
97+
98+
```$ git checkout [branch-name]```
99+
100+
Switches to the specified branch and updates working directory
101+
102+
103+
```$ git merge [branch-name]```
104+
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
114+
Relocate and remove versioned files
115+
116+
117+
```$ git rm [file]```
118+
119+
Deletes the file from the working directory and stages the deletion
120+
121+
122+
```$ git rm --cached [file]```
123+
124+
Removes the file from version control but preserves the file locally
125+
126+
127+
```$ git mv [file-original] [file-renamed]```
128+
129+
Changes the file name and prepare it for commit
130+
131+
## Suppress tracking
132+
Exclude temporary files and paths
133+
134+
```
135+
*.log
136+
build/
137+
temp-*
138+
```
139+
140+
A text file named `.gitignore` suppresses accidental versioning of files and paths matching the specified patterns
141+
142+
143+
```$ git ls-files --other --ignored --exclude-standard```
144+
145+
Lists all ignored files in this project
146+
147+
## Save fragments
148+
Shelve and restore incomplete changes
149+
150+
151+
```$ git stash```
152+
153+
Temporarily stores all modified tracked files
154+
155+
156+
```$ git stash pop```
157+
158+
Restores the most recent stashed files
159+
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
169+
170+
## Review history
171+
Browse and inspect the evolution of project files
172+
173+
174+
```$ git log```
175+
176+
Lists version history for the current branch
177+
178+
179+
```$ git log --follow [file]```
180+
181+
Lists version history for the file, including renames
182+
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
192+
193+
## Redo commits
194+
Erase mistakes and craft replacement history
195+
196+
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
205+
206+
## Synchronize changes
207+
Register a repository bookmark and exchange version history
208+
209+
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+
224+
225+
```$ git pull```
226+
227+
Downloads bookmark history and incorporates changes
228+
229+
---
230+
231+
## GitHub Training
232+
Learn more about using GitHub and Git. Email the Training Team or visit our web site for learning event schedules and private class availability.
233+
234+
235+
* training.github.com

0 commit comments

Comments
 (0)