|
100 | 100 |
|
101 | 101 | 10. ### Workspace synchronization from Repository (Workspace <-- Repository)
|
102 | 102 |
|
103 | | - # merge the specified branch to the current branch. |
104 | | - $ git merge [branch] |
| 103 | + # merge the specified branch to the current branch. |
| 104 | + $ git merge [branch] |
105 | 105 |
|
106 | | - # merge a branch into a target branch |
107 | | - $ git merge [source branch] [target branch] |
| 106 | + # merge a branch into a target branch |
| 107 | + $ git merge [source branch] [target branch] |
108 | 108 |
|
109 | 109 | 11. ### Workspace synchronization from remote (Workspace <-- Repository <-- Remote)
|
110 | 110 |
|
111 | | - # Retrieve the changes to the Remote Repository and merge with the local branch (fetch+merge) |
112 | | - $ git pull origin [branch] |
| 111 | + # Retrieve the changes to the Remote Repository and merge with the local branch (fetch+merge) |
| 112 | + $ git pull origin [branch] |
113 | 113 |
|
114 | 114 | 12. ### View Information
|
115 | 115 |
|
116 | | - # Display the changed files. |
117 | | - $ git status |
| 116 | + # Display the changed files. |
| 117 | + $ git status |
118 | 118 |
|
119 | | - # Display the version history of the current branch. |
120 | | - $ git log |
| 119 | + # Display the version history of the current branch. |
| 120 | + $ git log |
121 | 121 |
|
122 | | - # Display the commit history, and the changed files for each commit. |
123 | | - $ git log --stat |
| 122 | + # Display the commit history, and the changed files for each commit. |
| 123 | + $ git log --stat |
124 | 124 |
|
125 | | - # Search commit history, according the keyword. |
126 | | - $ git log -S [keyword] |
| 125 | + # Search commit history, according the keyword. |
| 126 | + $ git log -S [keyword] |
127 | 127 |
|
128 | | - # Display all changes since a certain commit, occupying one line for one commit. |
129 | | - $ git log [tag] HEAD --pretty=format:%s |
| 128 | + # Display all changes since a certain commit, occupying one line for one commit. |
| 129 | + $ git log [tag] HEAD --pretty=format:%s |
130 | 130 |
|
131 | | - # Display all changes since a certain commit, and its "commit description" must meet the search criteria. |
132 | | - $ git log [tag] HEAD --grep feature |
| 131 | + # Display all changes since a certain commit, and its "commit description" must meet the search criteria. |
| 132 | + $ git log [tag] HEAD --grep feature |
133 | 133 |
|
134 | | - # Display the version history of a certain file. |
135 | | - $ git log --follow [file] |
136 | | - $ git whatchanged [file] |
| 134 | + # Display the version history of a certain file. |
| 135 | + $ git log --follow [file] |
| 136 | + $ git whatchanged [file] |
137 | 137 |
|
138 | | - # Display each diff related to the specified file. |
139 | | - $ git log -p [file] |
| 138 | + # Display each diff related to the specified file. |
| 139 | + $ git log -p [file] |
140 | 140 |
|
141 | | - # Display the past 5 commits. |
142 | | - $ git log -5 --pretty --oneline |
| 141 | + # Display the past 5 commits. |
| 142 | + $ git log -5 --pretty --oneline |
143 | 143 |
|
144 | | - # Display all the users who have committed, sorted by number of commits. |
145 | | - $ git shortlog -sn |
| 144 | + # Display all the users who have committed, sorted by number of commits. |
| 145 | + $ git shortlog -sn |
146 | 146 |
|
147 | | - # Display when and by whom the specified file was modified. |
148 | | - $ git blame [file] |
| 147 | + # Display when and by whom the specified file was modified. |
| 148 | + $ git blame [file] |
149 | 149 |
|
150 | | - # Display the difference between the Index and the Workspace. |
151 | | - $ git diff |
| 150 | + # Display the difference between the Index and the Workspace. |
| 151 | + $ git diff |
152 | 152 |
|
153 | | - # Display the difference between the Index and the previous commit. |
154 | | - $ git diff --cached [file] |
| 153 | + # Display the difference between the Index and the previous commit. |
| 154 | + $ git diff --cached [file] |
155 | 155 |
|
156 | | - # Display the difference between the Workspace and the latest commit of the current branch. |
157 | | - $ git diff HEAD |
| 156 | + # Display the difference between the Workspace and the latest commit of the current branch. |
| 157 | + $ git diff HEAD |
158 | 158 |
|
159 | | - # Display the difference between two commits. |
160 | | - $ git diff [first-branch]...[second-branch] |
| 159 | + # Display the difference between two commits. |
| 160 | + $ git diff [first-branch]...[second-branch] |
161 | 161 |
|
162 | | - # Display how many lines of code you have written today. |
163 | | - $ git diff --shortstat "@{0 day ago}" |
| 162 | + # Display how many lines of code you have written today. |
| 163 | + $ git diff --shortstat "@{0 day ago}" |
164 | 164 |
|
165 | | - # Show the metadata and the changed content for a certain commit. |
166 | | - $ git show [commit] |
| 165 | + # Show the metadata and the changed content for a certain commit. |
| 166 | + $ git show [commit] |
167 | 167 |
|
168 | | - # Show the changed file for a certain commit. |
169 | | - $ git show --name-only [commit] |
| 168 | + # Show the changed file for a certain commit. |
| 169 | + $ git show --name-only [commit] |
170 | 170 |
|
171 | | - # Show the contents of a certain file for a certain commit. |
172 | | - $ git show [commit]:[filename] |
| 171 | + # Show the contents of a certain file for a certain commit. |
| 172 | + $ git show [commit]:[filename] |
173 | 173 |
|
174 | | - # Show the latest commits of the current branch. |
175 | | - $ git reflog |
| 174 | + # Show the latest commits of the current branch. |
| 175 | + $ git reflog |
176 | 176 |
|
177 | 177 |
|
178 | 178 |
|
179 | 179 | 12. ### Branching
|
180 | 180 |
|
181 | | - # List all local branches. (the asterisk denotes the current branch) |
182 | | - $ git branch |
| 181 | + # List all local branches. (the asterisk denotes the current branch) |
| 182 | + $ git branch |
183 | 183 |
|
184 | | - # List all remote branches. |
185 | | - $ git branch -r |
| 184 | + # List all remote branches. |
| 185 | + $ git branch -r |
186 | 186 |
|
187 | | - # List all local branches and remote branches. |
188 | | - $ git branch -a |
| 187 | + # List all local branches and remote branches. |
| 188 | + $ git branch -a |
189 | 189 |
|
190 | | - # Create a new branch, but still stay in the current branch. |
191 | | - $ git branch [branch-name] |
| 190 | + # Create a new branch, but still stay in the current branch. |
| 191 | + $ git branch [branch-name] |
192 | 192 |
|
193 | | - # Create a new branch and switch to the branch. |
194 | | - $ git checkout -b [branch] |
| 193 | + # Create a new branch and switch to the branch. |
| 194 | + $ git checkout -b [branch] |
195 | 195 |
|
196 | | - # Switch to the specified branch and update the workspace. |
197 | | - $ git checkout [branch-name] |
| 196 | + # Switch to the specified branch and update the workspace. |
| 197 | + $ git checkout [branch-name] |
198 | 198 |
|
199 | | - # Switch to the previous branch. |
200 | | - $ git checkout - |
| 199 | + # Switch to the previous branch. |
| 200 | + $ git checkout - |
201 | 201 |
|
202 | | - # Delete the branch. |
203 | | - $ git branch -d [branch-name] |
204 | | - |
205 | | - # Delete the remote branch. |
206 | | - $ git push origin --delete [branch-name] |
207 | | - $ git branch -dr [remote/branch] |
| 202 | + # Delete the branch. |
| 203 | + $ git branch -d [branch-name] |
| 204 | + |
| 205 | + # Delete the remote branch. |
| 206 | + $ git push origin --delete [branch-name] |
| 207 | + $ git branch -dr [remote/branch] |
208 | 208 |
|
209 | 209 |
|
210 | 210 | 13. ### Ignore files and folder
|
211 | 211 |
|
212 | | - # Delete the files in the Workspace and put this deletion into the Index. |
213 | | - $ git rm [file1] [file2] ... |
| 212 | + # Delete the files in the Workspace and put this deletion into the Index. |
| 213 | + $ git rm [file1] [file2] ... |
214 | 214 |
|
215 | 215 |
|
216 | | - # Stop tracking the specified file, but the file will be remained in the Workspace. |
217 | | - $ git rm --cached [file] |
| 216 | + # Stop tracking the specified file, but the file will be remained in the Workspace. |
| 217 | + $ git rm --cached [file] |
218 | 218 |
|
219 | 219 | 14. ### Tag
|
220 | 220 |
|
221 | | - # List all tags. |
222 | | - $ git tag |
| 221 | + # List all tags. |
| 222 | + $ git tag |
223 | 223 |
|
224 | | - # Create a new tag in the current commit. |
225 | | - $ git tag [tag] |
| 224 | + # Create a new tag in the current commit. |
| 225 | + $ git tag [tag] |
226 | 226 |
|
227 | | - # Create a new tag in the specified commit. |
228 | | - $ git tag [tag] [commit] |
| 227 | + # Create a new tag in the specified commit. |
| 228 | + $ git tag [tag] [commit] |
229 | 229 |
|
230 | | - # Delete the local tag. |
231 | | - $ git tag -d [tag] |
| 230 | + # Delete the local tag. |
| 231 | + $ git tag -d [tag] |
232 | 232 |
|
233 | | - # Delete the remote tag. |
234 | | - $ git push origin :refs/tags/[tagName] |
| 233 | + # Delete the remote tag. |
| 234 | + $ git push origin :refs/tags/[tagName] |
235 | 235 |
|
236 | | - # View the tag information. |
237 | | - $ git show [tag] |
| 236 | + # View the tag information. |
| 237 | + $ git show [tag] |
238 | 238 |
|
239 | | - # Commit the specified tag. |
240 | | - $ git push [remote] [tag] |
| 239 | + # Commit the specified tag. |
| 240 | + $ git push [remote] [tag] |
241 | 241 |
|
242 | | - # Commit all tags. |
243 | | - $ git push [remote] --tags |
| 242 | + # Commit all tags. |
| 243 | + $ git push [remote] --tags |
244 | 244 |
|
245 | | - # Create a new branch pointing to a certain tag |
246 | | - $ git checkout -b [branch] [tag] |
| 245 | + # Create a new branch pointing to a certain tag |
| 246 | + $ git checkout -b [branch] [tag] |
247 | 247 |
|
248 | 248 |
|
249 | 249 |
|
|
0 commit comments