Skip to content

Commit c4a2705

Browse files
author
jordanmccullough
committed
Add Markdown format of Git Cheat Sheet
1 parent 337fcbb commit c4a2705

File tree

1 file changed

+166
-0
lines changed

1 file changed

+166
-0
lines changed

downloads/github-git-cheat-sheet.md

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
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+
https://windows.github.com
10+
11+
### GitHub for Mac
12+
https://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+
```git config --global user.name "[name]"```
23+
Set your name that will be recorded for commit transactions
24+
25+
```git config --global user.email "[email address]"```
26+
Set your email address that will be saved for commit transations
27+
28+
```git config --global color.ui auto```
29+
Enable helpful colorization of command line output
30+
31+
32+
## Create repositories
33+
Start a new repository or obtain one from an existing URL
34+
35+
```git init [project-name]```
36+
Create a new local repository with the specified name
37+
38+
```git clone [url]```
39+
Download a project and its entire version history
40+
41+
## Make changes
42+
Review edits and craft a commit transaction
43+
44+
```git status```
45+
List all new or modified files to be committed
46+
47+
```git diff```
48+
Show file differences not yet staged
49+
50+
```git add [file]```
51+
Snapshot the file in preparation for versioning
52+
53+
```git diff --staged```
54+
Show file differences between staging and the last file version
55+
56+
```git reset [file]```
57+
Remove the file from the staging area
58+
59+
```git commit -m"[descriptive message]"```
60+
Record file snapshots permanently in version history
61+
62+
## Group changes
63+
Name a series of commits and combine completed efforts
64+
65+
```git branch```
66+
List all local branches to the current repository
67+
68+
```git branch [branch-name]```
69+
Create a new branch
70+
71+
```git checkout [branch-name]```
72+
Switch branches with respect to its specific commits
73+
74+
```git merge [branch-name]```
75+
Combine the specified branch’s history into the current one
76+
77+
```git branch -d [branch-name]```
78+
Delete the specified branch
79+
80+
81+
## Refactor filenames
82+
Relocate and remove versioned files
83+
84+
```git rm [file]```
85+
Delete the file from the project prepare the removal for commit
86+
87+
```git rm --cached [file]```
88+
Remove the file from version control but keep in project directory
89+
90+
```git mv [file-original] [file-renamed]```
91+
Change the filename and prepare it for commit
92+
93+
## Supress tracking
94+
Exclude temporary files and paths
95+
96+
```
97+
*.log
98+
build/
99+
temp-*
100+
```
101+
Create a _.gitignore_ text file supress accidental versioning of files and paths matching the specified glob patterns
102+
103+
```git ls-files --other --ignored --exclude-standard```
104+
List all ignore pattern matched files in project
105+
106+
## Save fragments
107+
Shelve and restore incomplete changes
108+
109+
```git stash```
110+
Temporarily store all modified, tracked files
111+
112+
```git stash pop```
113+
Restore the most recent stashed files
114+
115+
```git stash list```
116+
List all shelved changes
117+
118+
```git stash drop```
119+
Discard the most recent stashed files
120+
121+
## Review history
122+
Browse and inspect the evolution of project files
123+
124+
```git log```
125+
List all version history for the current branch
126+
127+
```git log --follow [file]```
128+
List version history for a file and possible renames
129+
130+
```git diff [first-branch]...[second-branch]```
131+
Show content differences between two branches
132+
133+
```git show [commit]```
134+
Output all details of the specified commit
135+
136+
## Redo commits
137+
Erase mistakes and craft replacement history
138+
139+
```git reset [commit]```
140+
Undo all commits after commit while preserving changes
141+
142+
```git reset --hard [commit]```
143+
Discard all history and changes back to specified commit
144+
145+
## Synchronize changes
146+
Register a repository bookmark and exchange version history
147+
148+
```git fetch [bookmark]```
149+
Download all history from the repository bookmark
150+
151+
```git merge [bookmark]/[branch]```
152+
Combine bookmark’s branch into into current local brancha
153+
154+
```git push [alias] [branch]```
155+
Upload all local branch commits to GitHub
156+
157+
```git pull```
158+
Sychronize bookmark history and current branch all at once
159+
160+
---
161+
162+
## GitHub Training
163+
Learn more about using GitHub and Git. Email the Training Team or visit our web site for learning event schedules and private class availability.
164+
165+
166+
* trianing.github.com

0 commit comments

Comments
 (0)