Git merge rebase cherry-pick 以及 游离commit 的测试

  1 Microsoft Windows [版本 10.0.17134.345]
  2 (c) 2018 Microsoft Corporation。保留所有权利。
  3 
  4 C:\Users\zhangyang\Desktop\branch>git init
  5 Initialized empty Git repository in C:/Users/zhangyang/Desktop/branch/.git/
  6 
  7 C:\Users\zhangyang\Desktop\branch>git commit -m "Init Commit" --allow-empty
  8 [master (root-commit) 468be32] Init Commit
  9 
 10 C:\Users\zhangyang\Desktop\branch>git commit -m "C1" --allow-empty
 11 [master f91e414] C1
 12 
 13 C:\Users\zhangyang\Desktop\branch>git commit -m "C2" --allow-empty
 14 [master c738d28] C2
 15 
 16 C:\Users\zhangyang\Desktop\branch>git commit -m "C3" --allow-empty
 17 [master 09c5904] C3
 18 
 19 C:\Users\zhangyang\Desktop\branch>git checkout -b branch1
 20 Switched to a new branch 'branch1'
 21 
 22 C:\Users\zhangyang\Desktop\branch>git commit -m "C4" --allow-empty
 23 [branch1 60f5e77] C4
 24 
 25 C:\Users\zhangyang\Desktop\branch>git commit -m "C5" --allow-empty
 26 [branch1 85a8fe7] C5
 27 
 28 C:\Users\zhangyang\Desktop\branch>git log --oneline --decorate --graph --all
 29 * 85a8fe7 (HEAD -> branch1) C5
 30 * 60f5e77 C4
 31 * 09c5904 (master) C3
 32 * c738d28 C2
 33 * f91e414 C1
 34 * 468be32 Init Commit
 35 
 36 C:\Users\zhangyang\Desktop\branch>git checkout 85a9fe7
 37 error: pathspec '85a9fe7' did not match any file(s) known to git.
 38 
 39 C:\Users\zhangyang\Desktop\branch>git checkout 85a8fe7
 40 Note: checking out '85a8fe7'.
 41 
 42 You are in 'detached HEAD' state. You can look around, make experimental
 43 changes and commit them, and you can discard any commits you make in this
 44 state without impacting any branches by performing another checkout.
 45 
 46 If you want to create a new branch to retain commits you create, you may
 47 do so (now or later) by using -b with the checkout command again. Example:
 48 
 49   git checkout -b <new-branch-name>
 50 
 51 HEAD is now at 85a8fe7 C5
 52 
 53 C:\Users\zhangyang\Desktop\branch>git commit -m "C6" --allow-empty
 54 [detached HEAD 3f0d0e2] C6
 55 
 56 C:\Users\zhangyang\Desktop\branch>git commit -m "C7" --allow-empty
 57 [detached HEAD 9724be1] C7
 58 
 59 C:\Users\zhangyang\Desktop\branch>git commit -m "C8" --allow-empty
 60 [detached HEAD ba2e2d2] C8
 61 
 62 C:\Users\zhangyang\Desktop\branch>git status
 63 HEAD detached from 85a8fe7
 64 nothing to commit, working tree clean
 65 
 66 C:\Users\zhangyang\Desktop\branch>git log --oneline --decorate --graph --all
 67 * ba2e2d2 (HEAD) C8
 68 * 9724be1 C7
 69 * 3f0d0e2 C6
 70 * 85a8fe7 (branch1) C5
 71 * 60f5e77 C4
 72 * 09c5904 (master) C3
 73 * c738d28 C2
 74 * f91e414 C1
 75 * 468be32 Init Commit
 76 
 77 C:\Users\zhangyang\Desktop\branch>git show 3f0d0e2
 78 commit 3f0d0e290a94035f504cb1fb43065b09ed782172
 79 Author: yqmcu <yqmcu@foxmail.com>
 80 Date:   Mon Feb 25 08:13:54 2019 +0800
 81 
 82     C6
 83 
 84 C:\Users\zhangyang\Desktop\branch>git show 85a8fe7
 85 commit 85a8fe7ad54cde82285d866536a8d7cd6d74f6cb (branch1)
 86 Author: yqmcu <yqmcu@foxmail.com>
 87 Date:   Mon Feb 25 08:12:41 2019 +0800
 88 
 89     C5
 90 
 91 C:\Users\zhangyang\Desktop\branch>git checkout -b HEAD
 92 fatal: 'HEAD' is not a valid branch name.
 93 
 94 C:\Users\zhangyang\Desktop\branch>git checkout -b detached
 95 Switched to a new branch 'detached'
 96 
 97 C:\Users\zhangyang\Desktop\branch>git log --oneline --decorate --all --graph
 98 * ba2e2d2 (HEAD -> detached) C8
 99 * 9724be1 C7
100 * 3f0d0e2 C6
101 * 85a8fe7 (branch1) C5
102 * 60f5e77 C4
103 * 09c5904 (master) C3
104 * c738d28 C2
105 * f91e414 C1
106 * 468be32 Init Commit
107 
108 C:\Users\zhangyang\Desktop\branch>git checkout branch1
109 Switched to branch 'branch1'
110 
111 C:\Users\zhangyang\Desktop\branch>git cherry-pick detached
112 The previous cherry-pick is now empty, possibly due to conflict resolution.
113 If you wish to commit it anyway, use:
114 
115     git commit --allow-empty
116 
117 Otherwise, please use 'git reset'
118 On branch branch1
119 You are currently cherry-picking commit ba2e2d2.
120 
121 nothing to commit, working tree clean
122 
123 C:\Users\zhangyang\Desktop\branch>git log --oneline --decorate --all --graph
124 * ba2e2d2 (detached) C8
125 * 9724be1 C7
126 * 3f0d0e2 C6
127 * 85a8fe7 (HEAD -> branch1) C5
128 * 60f5e77 C4
129 * 09c5904 (master) C3
130 * c738d28 C2
131 * f91e414 C1
132 * 468be32 Init Commit
133 
134 C:\Users\zhangyang\Desktop\branch>git commit --allow-empty
135 [branch1 7edcbff] C8
136  Date: Mon Feb 25 08:14:02 2019 +0800
137 
138 C:\Users\zhangyang\Desktop\branch>git log --oneline --decorate --all --graph
139 * 7edcbff (HEAD -> branch1) C8
140 | * ba2e2d2 (detached) C8
141 | * 9724be1 C7
142 | * 3f0d0e2 C6
143 |/
144 * 85a8fe7 C5
145 * 60f5e77 C4
146 * 09c5904 (master) C3
147 * c738d28 C2
148 * f91e414 C1
149 * 468be32 Init Commit
150 
151 C:\Users\zhangyang\Desktop\branch>git log --oneline --decorate  --graph
152 * 7edcbff (HEAD -> branch1) C8
153 * 85a8fe7 C5
154 * 60f5e77 C4
155 * 09c5904 (master) C3
156 * c738d28 C2
157 * f91e414 C1
158 * 468be32 Init Commit
159 
160 C:\Users\zhangyang\Desktop\branch>git checkout master
161 Switched to branch 'master'
162 
163 C:\Users\zhangyang\Desktop\branch>git rebase merge branch1 --no-ff
164 fatal: Needed a single revision
165 invalid upstream 'merge'
166 
167 C:\Users\zhangyang\Desktop\branch>git merge branch1 --no-ff
168 Already up to date!
169 Merge made by the 'recursive' strategy.
170 
171 C:\Users\zhangyang\Desktop\branch>git log --oneline --decorate  --graph
172 *   6e2328f (HEAD -> master) Merge branch 'branch1'
173 |\
174 | * 7edcbff (branch1) C8
175 | * 85a8fe7 C5
176 | * 60f5e77 C4
177 |/
178 * 09c5904 C3
179 * c738d28 C2
180 * f91e414 C1
181 * 468be32 Init Commit
182 
183 C:\Users\zhangyang\Desktop\branch>git log --oneline --decorate  --graph --all
184 *   6e2328f (HEAD -> master) Merge branch 'branch1'
185 |\
186 | * 7edcbff (branch1) C8
187 | | * ba2e2d2 (detached) C8
188 | | * 9724be1 C7
189 | | * 3f0d0e2 C6
190 | |/
191 | * 85a8fe7 C5
192 | * 60f5e77 C4
193 |/
194 * 09c5904 C3
195 * c738d28 C2
196 * f91e414 C1
197 * 468be32 Init Commit
198 
199 C:\Users\zhangyang\Desktop\branch>git checkout -b --help
200 fatal: '--help' is not a valid branch name.
201 
202 C:\Users\zhangyang\Desktop\branch>git checkout --help
203 
204 C:\Users\zhangyang\Desktop\branch>git checkout -b old 85a8fe7
205 Switched to a new branch 'old'
206 
207 C:\Users\zhangyang\Desktop\branch>git log --oneline --graph
208 * 85a8fe7 (HEAD -> old) C5
209 * 60f5e77 C4
210 * 09c5904 C3
211 * c738d28 C2
212 * f91e414 C1
213 * 468be32 Init Commit
214 
215 C:\Users\zhangyang\Desktop\branch>git cherry-pick branch1
216 The previous cherry-pick is now empty, possibly due to conflict resolution.
217 If you wish to commit it anyway, use:
218 
219     git commit --allow-empty
220 
221 Otherwise, please use 'git reset'
222 On branch old
223 You are currently cherry-picking commit 7edcbff.
224 
225 nothing to commit, working tree clean
226 
227 C:\Users\zhangyang\Desktop\branch>git commit --allow-empty
228 [old 11d5930] C8
229  Date: Mon Feb 25 08:14:02 2019 +0800
230 
231 C:\Users\zhangyang\Desktop\branch>git log --oneline --graph
232 * 11d5930 (HEAD -> old) C8
233 * 85a8fe7 C5
234 * 60f5e77 C4
235 * 09c5904 C3
236 * c738d28 C2
237 * f91e414 C1
238 * 468be32 Init Commit
239 
240 C:\Users\zhangyang\Desktop\branch>git reset 85a8fe7 --hard
241 HEAD is now at 85a8fe7 C5
242 
243 C:\Users\zhangyang\Desktop\branch>git log --oneline --graph
244 * 85a8fe7 (HEAD -> old) C5
245 * 60f5e77 C4
246 * 09c5904 C3
247 * c738d28 C2
248 * f91e414 C1
249 * 468be32 Init Commit
250 
251 C:\Users\zhangyang\Desktop\branch>git rebase branch1
252 First, rewinding head to replay your work on top of it...
253 Fast-forwarded old to branch1.
254 
255 C:\Users\zhangyang\Desktop\branch>git log --oneline --graph
256 * 7edcbff (HEAD -> old, branch1) C8
257 * 85a8fe7 C5
258 * 60f5e77 C4
259 * 09c5904 C3
260 * c738d28 C2
261 * f91e414 C1
262 * 468be32 Init Commit
263 
264 C:\Users\zhangyang\Desktop\branch>git reset 85a8fe7 --hard
265 HEAD is now at 85a8fe7 C5
266 
267 C:\Users\zhangyang\Desktop\branch>git log --oneline --graph
268 * 85a8fe7 (HEAD -> old) C5
269 * 60f5e77 C4
270 * 09c5904 C3
271 * c738d28 C2
272 * f91e414 C1
273 * 468be32 Init Commit
274 
275 C:\Users\zhangyang\Desktop\branch>git merge branch1 --no-ff
276 Already up to date!
277 Merge made by the 'recursive' strategy.
278 
279 C:\Users\zhangyang\Desktop\branch>git log --oneline --graph
280 *   a6aea9e (HEAD -> old) Merge branch 'branch1' into old
281 |\
282 | * 7edcbff (branch1) C8
283 |/
284 * 85a8fe7 C5
285 * 60f5e77 C4
286 * 09c5904 C3
287 * c738d28 C2
288 * f91e414 C1
289 * 468be32 Init Commit
290 
291 C:\Users\zhangyang\Desktop\branch>git reset 85a8fe7 --hard
292 HEAD is now at 85a8fe7 C5
293 
294 C:\Users\zhangyang\Desktop\branch>git rebase detached
295 First, rewinding head to replay your work on top of it...
296 Fast-forwarded old to detached.
297 
298 C:\Users\zhangyang\Desktop\branch>git log --oneline --graph
299 * ba2e2d2 (HEAD -> old, detached) C8
300 * 9724be1 C7
301 * 3f0d0e2 C6
302 * 85a8fe7 C5
303 * 60f5e77 C4
304 * 09c5904 C3
305 * c738d28 C2
306 * f91e414 C1
307 * 468be32 Init Commit
308 
309 C:\Users\zhangyang\Desktop\branch>git log --oneline --graph
310 * ba2e2d2 (HEAD -> old, detached) C8
311 * 9724be1 C7
312 * 3f0d0e2 C6
313 * 85a8fe7 C5
314 * 60f5e77 C4
315 * 09c5904 C3
316 * c738d28 C2
317 * f91e414 C1
318 * 468be32 Init Commit
319 
320 C:\Users\zhangyang\Desktop\branch>git log --oneline --graph --all --decorate
321 *   6e2328f (master) Merge branch 'branch1'
322 |\
323 | * 7edcbff (branch1) C8
324 | | * ba2e2d2 (HEAD -> old, detached) C8
325 | | * 9724be1 C7
326 | | * 3f0d0e2 C6
327 | |/
328 | * 85a8fe7 C5
329 | * 60f5e77 C4
330 |/
331 * 09c5904 C3
332 * c738d28 C2
333 * f91e414 C1
334 * 468be32 Init Commit
335 
336 C:\Users\zhangyang\Desktop\branch>git checkout master
337 Switched to branch 'master'
338 
339 C:\Users\zhangyang\Desktop\branch>git reset 09c5904 --hard
340 HEAD is now at 09c5904 C3
341 
342 C:\Users\zhangyang\Desktop\branch>git log --oneline --graph --all --decorate
343 * 7edcbff (branch1) C8
344 | * ba2e2d2 (old, detached) C8
345 | * 9724be1 C7
346 | * 3f0d0e2 C6
347 |/
348 * 85a8fe7 C5
349 * 60f5e77 C4
350 * 09c5904 (HEAD -> master) C3
351 * c738d28 C2
352 * f91e414 C1
353 * 468be32 Init Commit
354 
355 C:\Users\zhangyang\Desktop\branch>git checkout branch1
356 Switched to branch 'branch1'
357 
358 C:\Users\zhangyang\Desktop\branch>git reset 85a8fe7 --hard
359 HEAD is now at 85a8fe7 C5
360 
361 C:\Users\zhangyang\Desktop\branch>git log --oneline --graph --all --decorate
362 * ba2e2d2 (old, detached) C8
363 * 9724be1 C7
364 * 3f0d0e2 C6
365 * 85a8fe7 (HEAD -> branch1) C5
366 * 60f5e77 C4
367 * 09c5904 (master) C3
368 * c738d28 C2
369 * f91e414 C1
370 * 468be32 Init Commit
371 
372 C:\Users\zhangyang\Desktop\branch>git rebase detached
373 First, rewinding head to replay your work on top of it...
374 Fast-forwarded branch1 to detached.
375 
376 C:\Users\zhangyang\Desktop\branch>git log --oneline --graph --all --decorate
377 * ba2e2d2 (HEAD -> branch1, old, detached) C8
378 * 9724be1 C7
379 * 3f0d0e2 C6
380 * 85a8fe7 C5
381 * 60f5e77 C4
382 * 09c5904 (master) C3
383 * c738d28 C2
384 * f91e414 C1
385 * 468be32 Init Commit
386 
387 C:\Users\zhangyang\Desktop\branch>git checkout master
388 Switched to branch 'master'
389 
390 C:\Users\zhangyang\Desktop\branch>git log --oneline --graph --all --decorate
391 * ba2e2d2 (old, detached, branch1) C8
392 * 9724be1 C7
393 * 3f0d0e2 C6
394 * 85a8fe7 C5
395 * 60f5e77 C4
396 * 09c5904 (HEAD -> master) C3
397 * c738d28 C2
398 * f91e414 C1
399 * 468be32 Init Commit
400 
401 C:\Users\zhangyang\Desktop\branch>git merge branch1 --no-ff
402 Already up to date!
403 Merge made by the 'recursive' strategy.
404 
405 C:\Users\zhangyang\Desktop\branch>git log --oneline --graph --all --decorate
406 *   6e056d3 (HEAD -> master) Merge branch 'branch1'
407 |\
408 | * ba2e2d2 (old, detached, branch1) C8
409 | * 9724be1 C7
410 | * 3f0d0e2 C6
411 | * 85a8fe7 C5
412 | * 60f5e77 C4
413 |/
414 * 09c5904 C3
415 * c738d28 C2
416 * f91e414 C1
417 * 468be32 Init Commit
418 
419 C:\Users\zhangyang\Desktop\branch>

 

posted @ 2019-02-25 10:56  缘起花渊  阅读(244)  评论(0编辑  收藏  举报