You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+84-84
Original file line number
Diff line number
Diff line change
@@ -105,145 +105,145 @@ Though there are 1000’s of articles about git, I have written this article is
105
105
106
106
10.### Workspace synchronization from Repository (Workspace <-- Repository)
107
107
108
-
# merge the specified branch to the current branch.
109
-
$ git merge [branch]
108
+
# merge the specified branch to the current branch.
109
+
$ git merge [branch]
110
110
111
-
# merge a branch into a target branch
112
-
$ git merge [source branch][target branch]
111
+
# merge a branch into a target branch
112
+
$ git merge [source branch] [target branch]
113
113
114
114
11.### Workspace synchronization from remote (Workspace <-- Repository <-- Remote)
115
115
116
-
# Retrieve the changes to the Remote Repository and merge with the local branch (fetch+merge)
117
-
$ git pull origin [branch]
116
+
# Retrieve the changes to the Remote Repository and merge with the local branch (fetch+merge)
117
+
$ git pull origin [branch]
118
118
119
119
12.### Branching
120
120
121
-
# List all local branches. (the asterisk denotes the current branch)
122
-
$ git branch
121
+
# List all local branches. (the asterisk denotes the current branch)
122
+
$ git branch
123
123
124
-
# List all remote branches.
125
-
$ git branch -r
124
+
# List all remote branches.
125
+
$ git branch -r
126
126
127
-
# List all local branches and remote branches.
128
-
$ git branch -a
127
+
# List all local branches and remote branches.
128
+
$ git branch -a
129
129
130
-
# Create a new branch, but still stay in the current branch.
131
-
$ git branch [branch-name]
130
+
# Create a new branch, but still stay in the current branch.
131
+
$ git branch [branch-name]
132
132
133
-
# Create a new branch and switch to the branch.
134
-
$ git checkout -b [branch]
133
+
# Create a new branch and switch to the branch.
134
+
$ git checkout -b [branch]
135
135
136
-
# Switch to the specified branch and update the workspace.
137
-
$ git checkout [branch-name]
136
+
# Switch to the specified branch and update the workspace.
137
+
$ git checkout [branch-name]
138
138
139
-
# Switch to the previous branch.
140
-
$ git checkout -
139
+
# Switch to the previous branch.
140
+
$ git checkout -
141
141
142
-
# Delete the branch.
143
-
$ git branch -d [branch-name]
142
+
# Delete the branch.
143
+
$ git branch -d [branch-name]
144
144
145
-
# Delete the remote branch.
146
-
$ git push origin --delete [branch-name]
147
-
$ git branch -dr [remote/branch]
145
+
# Delete the remote branch.
146
+
$ git push origin --delete [branch-name]
147
+
$ git branch -dr [remote/branch]
148
148
149
149
13.### View Information
150
150
151
-
# Display the changed files.
152
-
$ git status
151
+
# Display the changed files.
152
+
$ git status
153
153
154
-
# Display the version history of the current branch.
155
-
$ git log
154
+
# Display the version history of the current branch.
155
+
$ git log
156
156
157
-
# Display the past 5 commits.
158
-
$ git log -5 --pretty --oneline
157
+
# Display the past 5 commits.
158
+
$ git log -5 --pretty --oneline
159
159
160
-
# Display all the users who have committed, sorted by number of commits.
161
-
$ git shortlog -sn
160
+
# Display all the users who have committed, sorted by number of commits.
161
+
$ git shortlog -sn
162
162
163
-
# Show the latest commits of the current branch.
164
-
$ git reflog
163
+
# Show the latest commits of the current branch.
164
+
$ git reflog
165
165
166
166
14.### Ignore files and folder
167
167
168
-
# Delete the files in the Workspace and put this deletion into the Staging.
169
-
$ git rm [file1][file2] ...
168
+
# Delete the files in the Workspace and put this deletion into the Staging.
169
+
$ git rm [file1] [file2] ...
170
170
171
171
172
-
# Stop tracking the specified file, but the file will be remained in the Workspace.
173
-
$ git rm --cached [file]
172
+
# Stop tracking the specified file, but the file will be remained in the Workspace.
173
+
$ git rm --cached [file]
174
174
175
175
15.### Tag
176
176
177
-
# List all tags.
178
-
$ git tag
177
+
# List all tags.
178
+
$ git tag
179
179
180
-
# Create a new tag in the current commit.
181
-
$ git tag [tag]
180
+
# Create a new tag in the current commit.
181
+
$ git tag [tag]
182
182
183
-
# Create a new tag in the specified commit.
184
-
$ git tag [tag][commit]
183
+
# Create a new tag in the specified commit.
184
+
$ git tag [tag] [commit]
185
185
186
-
# Delete the local tag.
187
-
$ git tag -d [tag]
186
+
# Delete the local tag.
187
+
$ git tag -d [tag]
188
188
189
-
# Delete the remote tag.
190
-
$ git push origin :refs/tags/[tagName]
189
+
# Delete the remote tag.
190
+
$ git push origin :refs/tags/[tagName]
191
191
192
-
# View the tag information.
193
-
$ git show [tag]
192
+
# View the tag information.
193
+
$ git show [tag]
194
194
195
-
# Commit the specified tag.
196
-
$ git push [remote][tag]
195
+
# Commit the specified tag.
196
+
$ git push [remote] [tag]
197
197
198
-
# Commit all tags.
199
-
$ git push [remote] --tags
198
+
# Commit all tags.
199
+
$ git push [remote] --tags
200
200
201
-
# Create a new branch pointing to a certain tag
202
-
$ git checkout -b [branch][tag]
201
+
# Create a new branch pointing to a certain tag
202
+
$ git checkout -b [branch] [tag]
203
203
204
204
205
205
16.### Revoke
206
206
207
-
# Restore the specified file of the Staging to the Workspace.
208
-
$ git checkout [file]
207
+
# Restore the specified file of the Staging to the Workspace.
208
+
$ git checkout [file]
209
209
210
-
# Restore the specified file of a certain commit to the Staging and Workspace.
211
-
$ git checkout [commit][file]
210
+
# Restore the specified file of a certain commit to the Staging and Workspace.
211
+
$ git checkout [commit] [file]
212
212
213
-
# Restore all the files in the Staging to the Workspace.
214
-
$ git checkout .
213
+
# Restore all the files in the Staging to the Workspace.
214
+
$ git checkout .
215
215
216
-
# Reset the specified file in the Staging, keeping consistent with the previous commit, but remaining the workspace unchanged.
217
-
$ git reset [file]
216
+
# Reset the specified file in the Staging, keeping consistent with the previous commit, but remaining the workspace unchanged.
217
+
$ git reset [file]
218
218
219
-
# Reset the Staging and workspace, keeping consistent with the last commit.
220
-
$ git reset --hard
219
+
# Reset the Staging and workspace, keeping consistent with the last commit.
220
+
$ git reset --hard
221
221
222
-
# Reset the pointer of the current branch to pointing the specified commit while resetting the Staging, but the workspace remains unchanged.
223
-
$ git reset [commit]
222
+
# Reset the pointer of the current branch to pointing the specified commit while resetting the Staging, but the workspace remains unchanged.
223
+
$ git reset [commit]
224
224
225
-
# Reset the HEAD of the current branch to the specified commit while resetting the Staging and Workspace, keeping consistent with the specified commit.
226
-
$ git reset --hard [commit]
225
+
# Reset the HEAD of the current branch to the specified commit while resetting the Staging and Workspace, keeping consistent with the specified commit.
226
+
$ git reset --hard [commit]
227
227
228
-
# Reset the current HEAD to the specified commit, remaining the Staging and Workspace unchanged.
229
-
$ git reset --keep [commit]
228
+
# Reset the current HEAD to the specified commit, remaining the Staging and Workspace unchanged.
229
+
$ git reset --keep [commit]
230
230
231
-
# Create a new commit to undo the specified commit.
232
-
# All changes of the latter will be offset by the former and applied to the current branch.
233
-
$ git revert [commit]
231
+
# Create a new commit to undo the specified commit.
232
+
# All changes of the latter will be offset by the former and applied to the current branch.
233
+
$ git revert [commit]
234
234
235
-
# Remove the uncommitted changes temporarily and move them in later.
236
-
$ git stash
237
-
$ git stash pop
235
+
# Remove the uncommitted changes temporarily and move them in later.
236
+
$ git stash
237
+
$ git stash pop
238
238
239
239
240
240
17.### Others
241
241
242
-
# Select a commit to be merged into the current branch.
243
-
$ git cherry-pick [commit]
242
+
# Select a commit to be merged into the current branch.
243
+
$ git cherry-pick [commit]
244
244
245
-
# Generate a archive for releasing.
246
-
$ git archive
245
+
# Generate a archive for releasing.
246
+
$ git archive
247
247
248
248
18.### References
249
249
@@ -253,5 +253,5 @@ Though there are 1000’s of articles about git, I have written this article is
0 commit comments