@@ -19,75 +19,75 @@ http://git-scm.com
19
19
## Configure tooling
20
20
Configure user information for all local repositories
21
21
22
- ``` git config --global user.name "[name]" ```
22
+ ``` $ git config --global user.name "[name]"```
23
23
Set the name you want attached to your commit transactions
24
24
25
- ``` git config --global user.email "[email address]" ```
25
+ ``` $ git config --global user.email "[email address]"```
26
26
Set the email you want attached to your commit transactions
27
27
28
- ``` git config --global color.ui auto ```
28
+ ``` $ git config --global color.ui auto```
29
29
Enable helpful colorization of command line output
30
30
31
31
32
32
## Create repositories
33
33
Start a new repository or obtain one from an existing URL
34
34
35
- ``` git init [project-name] ```
35
+ ``` $ git init [project-name]```
36
36
Create a new local repository with the specified name
37
37
38
- ``` git clone [url] ```
38
+ ``` $ git clone [url]```
39
39
Download a project and its entire version history
40
40
41
41
## Make changes
42
42
Review edits and craft a commit transaction
43
43
44
- ``` git status ```
44
+ ``` $ git status```
45
45
List all new or modified files to be committed
46
46
47
- ``` git diff ```
47
+ ``` $ git diff```
48
48
Show file differences not yet staged
49
49
50
- ``` git add [file] ```
50
+ ``` $ git add [file]```
51
51
Snapshot the file in preparation for versioning
52
52
53
- ``` git diff --staged ```
53
+ ``` $ git diff --staged```
54
54
Show file differences between staging and the last file version
55
55
56
- ``` git reset [file] ```
56
+ ``` $ git reset [file]```
57
57
Unstage the file, but preserve its contents
58
58
59
- ``` git commit -m"[descriptive message]" ```
59
+ ``` $ git commit -m"[descriptive message]"```
60
60
Record file snapshots permanently in version history
61
61
62
62
## Group changes
63
63
Name a series of commits and combine completed efforts
64
64
65
- ``` git branch ```
65
+ ``` $ git branch```
66
66
List all local branches in the current repository
67
67
68
- ``` git branch [branch-name] ```
68
+ ``` $ git branch [branch-name]```
69
69
Create a new branch
70
70
71
- ``` git checkout [branch-name] ```
71
+ ``` $ git checkout [branch-name]```
72
72
Switch to the specified branch and update working directory
73
73
74
- ``` git merge [branch-name] ```
74
+ ``` $ git merge [branch-name]```
75
75
Combine the specified branch’s history into the current branch
76
76
77
- ``` git branch -d [branch-name] ```
77
+ ``` $ git branch -d [branch-name]```
78
78
Delete the specified branch
79
79
80
80
81
81
## Refactor filenames
82
82
Relocate and remove versioned files
83
83
84
- ``` git rm [file] ```
84
+ ``` $ git rm [file]```
85
85
Delete the file from the working directory and stage the deletion
86
86
87
- ``` git rm --cached [file] ```
87
+ ``` $ git rm --cached [file]```
88
88
Remove from version control but preserve the file locally
89
89
90
- ``` git mv [file-original] [file-renamed] ```
90
+ ``` $ git mv [file-original] [file-renamed]```
91
91
Change the filename and prepare it for commit
92
92
93
93
## Supress tracking
@@ -100,61 +100,61 @@ temp-*
100
100
```
101
101
A text file named ` .gitignore ` suppresses accidental versioning of files and paths matching the specified patterns
102
102
103
- ``` git ls-files --other --ignored --exclude-standard ```
103
+ ``` $ git ls-files --other --ignored --exclude-standard```
104
104
List all ignored files in this project
105
105
106
106
## Save fragments
107
107
Shelve and restore incomplete changes
108
108
109
- ``` git stash ```
109
+ ``` $ git stash```
110
110
Temporarily store all modified tracked files
111
111
112
- ``` git stash pop ```
112
+ ``` $ git stash pop```
113
113
Restore the most recently stashed files
114
114
115
- ``` git stash list ```
115
+ ``` $ git stash list```
116
116
List all stashed changesets
117
117
118
- ``` git stash drop ```
118
+ ``` $ git stash drop```
119
119
Discard the most recently stashed changeset
120
120
121
121
## Review history
122
122
Browse and inspect the evolution of project files
123
123
124
- ``` git log ```
124
+ ``` $ git log```
125
125
List version history for the current branch
126
126
127
- ``` git log --follow [file] ```
127
+ ``` $ git log --follow [file]```
128
128
List version history for a file, including renames
129
129
130
- ``` git diff [first-branch]...[second-branch] ```
130
+ ``` $ git diff [first-branch]...[second-branch]```
131
131
Show content differences between two branches
132
132
133
- ``` git show [commit] ```
133
+ ``` $ git show [commit]```
134
134
Output metadata and content changes of the specified commit
135
135
136
136
## Redo commits
137
137
Erase mistakes and craft replacement history
138
138
139
- ``` git reset [commit] ```
139
+ ``` $ git reset [commit]```
140
140
Undo all commits after [ commit] , preserving changes locally
141
141
142
- ``` git reset --hard [commit] ```
142
+ ``` $ git reset --hard [commit]```
143
143
Discard all history and changes back to the specified commit
144
144
145
145
## Synchronize changes
146
146
Register a repository bookmark and exchange version history
147
147
148
- ``` git fetch [bookmark] ```
148
+ ``` $ git fetch [bookmark]```
149
149
Download all history from the repository bookmark
150
150
151
- ``` git merge [bookmark]/[branch] ```
151
+ ``` $ git merge [bookmark]/[branch]```
152
152
Combine bookmark’s branch into into current local branch
153
153
154
- ``` git push [alias] [branch] ```
154
+ ``` $ git push [alias] [branch]```
155
155
Upload all local branch commits to GitHub
156
156
157
- ``` git pull ```
157
+ ``` $ git pull```
158
158
Synchronize bookmark history and incorporate current branch changes
159
159
160
160
---
0 commit comments