@@ -19,75 +19,113 @@ http://git-scm.com
1919## Configure tooling
2020Configure user information for all local repositories
2121
22+
2223``` $ git config --global user.name "[name]" ```
24+
2325Sets the name you want attached to your commit transactions
2426
27+
2528``` $ git config --global user.email "[email address]" ```
29+
2630Sets the email you want attached to your commit transactions
2731
32+
2833``` $ git config --global color.ui auto ```
34+
2935Enables helpful colorization of command line output
3036
3137
3238## Create repositories
3339Starts a new repository or obtain one from an existing URL
3440
41+
3542``` $ git init [project-name] ```
43+
3644Creates a new local repository with the specified name
3745
46+
3847``` $ git clone [url] ```
48+
3949Downloads a project and its entire version history
4050
4151## Make changes
4252Reviews edits and craft a commit transaction
4353
54+
4455``` $ git status ```
56+
4557Lists all new or modified files to be committed
4658
59+
4760``` $ git diff ```
61+
4862Shows file differences not yet staged
4963
64+
5065``` $ git add [file] ```
66+
5167Snapshots the file in preparation for versioning
5268
69+
5370``` $ git diff --staged ```
71+
5472Shows file differences between staging and the last file version
5573
74+
5675``` $ git reset [file] ```
76+
5777Unstages the file, but preserve its contents
5878
79+
5980``` $ git commit -m"[descriptive message]" ```
81+
6082Records file snapshots permanently in version history
6183
6284## Group changes
6385Names a series of commits and combine completed efforts
6486
87+
6588``` $ git branch ```
89+
6690Lists all local branches in the current repository
6791
92+
6893``` $ git branch [branch-name] ```
94+
6995Creates a new branch
7096
97+
7198``` $ git checkout [branch-name] ```
99+
72100Switches to the specified branch and update working directory
73101
102+
74103``` $ git merge [branch-name] ```
104+
75105Combines the specified branch’s history into the current branch
76106
107+
77108``` $ git branch -d [branch-name] ```
109+
78110Deletes the specified branch
79111
80112
81113## Refactor filenames
82114Relocates and remove versioned files
83115
116+
84117``` $ git rm [file] ```
118+
85119Deletes the file from the working directory and stage the deletion
86120
121+
87122``` $ git rm --cached [file] ```
123+
88124Removes from version control but preserve the file locally
89125
126+
90127``` $ git mv [file-original] [file-renamed] ```
128+
91129Changes the filename and prepare it for commit
92130
93131## Supress tracking
@@ -98,63 +136,94 @@ Excludes temporary files and paths
98136build/
99137temp-*
100138```
139+
101140A 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+
104145Lists all ignored files in this project
105146
106147## Save fragments
107148Shelve and restore incomplete changes
108149
150+
109151``` $ git stash ```
152+
110153Temporarily stores all modified tracked files
111154
155+
112156``` $ git stash pop ```
157+
113158Restores the most recently stashed files
114159
160+
115161``` $ git stash list ```
162+
116163Lists all stashed changesets
117164
165+
118166``` $ git stash drop ```
167+
119168Discards the most recently stashed changeset
120169
121170## Review history
122171Browses and inspect the evolution of project files
123172
173+
124174``` $ git log ```
175+
125176Lists version history for the current branch
126177
178+
127179``` $ git log --follow [file] ```
180+
128181Lists version history for a file, including renames
129182
183+
130184``` $ git diff [first-branch]...[second-branch] ```
185+
131186Shows content differences between two branches
132187
188+
133189``` $ git show [commit] ```
190+
134191Outputs metadata and content changes of the specified commit
135192
136193## Redo commits
137194Erases mistakes and craft replacement history
138195
196+
139197``` $ git reset [commit] ```
198+
140199Undoes all commits after [ commit] , preserving changes locally
141200
201+
142202``` $ git reset --hard [commit] ```
203+
143204Discards all history and changes back to the specified commit
144205
145206## Synchronize changes
146207Registers a repository bookmark and exchange version history
147208
209+
148210``` $ git fetch [bookmark] ```
211+
149212Downloads all history from the repository bookmark
150213
214+
151215``` $ git merge [bookmark]/[branch] ```
216+
152217Combines bookmark’s branch into into current local branch
153218
219+
154220``` $ git push [alias] [branch] ```
221+
155222Uploads all local branch commits to GitHub
156223
224+
157225``` $ git pull ```
226+
158227Synchronizes bookmark history and incorporate current branch changes
159228
160229---
0 commit comments