先頭ポインタを分離

文化的背景

取り外しHEAD状態、ヘッド・ポインタの分離、即ちポインタポイントが直接ヘッド提出記録
通常、分岐HEADを指す必要が
実行した場合git checkout tag名git checkout 远端分支名、またはgit checkout 提交记录哈希值、HEAD点コミット・レコードをポイントするように、これは、ヘッドの状態を離脱します

実験

まずgitのログとグラフィカルソフトウェアgitのログを、実験の開始前に、レコードチェックテストツリー倉庫をコミット

$ git log
commit 314b5494eb06a9963f4e6f97075f2354c8a15f13 (HEAD -> master)
Author: MilesGO <[email protected]>
Date:   Sun Jun 9 17:20:40 2019 +0800

    add main2.cpp

commit 12c2c80788dcd74a1cd739157c0a1011514d36b2
Author: MilesGO <[email protected]>
Date:   Sun Jun 9 17:11:48 2019 +0800

    add src/main.cpp

commit 4a1d75425a4cd5c3e206a4c69415c59802175039
Author: MilesGO <[email protected]>
Date:   Sun Jun 9 17:00:08 2019 +0800

    modify README

commit 29c07152991c7b3ee41f9cb5ac1eff1f26610665
Author: MilesGO <[email protected]>
Date:   Sun Jun 9 16:52:41 2019 +0800

    add README

ビューでのgit-フォークした後、あなたは木が線形である全粒レコードを提出見ることができる
我々は提出最後から二番目に直接ハッシュ値を検出しました

$ git checkout 12c2c8
Note: checking out '12c2c8'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 12c2c80 add src/main.cpp

上記の翻訳、あなたが状態でヘッドポインタから分離されている、あなたには、いくつかの実験的な変更を行い、それらを提出することができますが、これらの提出は、あなたがそれらに分岐点を使用しない限り破棄されます
、現在のファイルの下で、この分岐はmain2.cppしていません私たちは、このファイルを追加します

$ echo 'hello world again' >> main2.cpp
$ git add main2.cpp
$ git commit -m 'add main2.cpp again'
[detached HEAD 11ed7f1] add main2.cpp again
 1 file changed, 1 insertion(+)
 create mode 100644 main2.cpp

$ git checkout master
Warning: you are leaving 1 commit behind, not connected to
any of your branches:

  11ed7f1 add main2.cpp again

If you want to keep it by creating a new branch, this may be a good time
to do so with:

 git branch <new-branch-name> 11ed7f1

Switched to branch 'master'

上記は、あなたがこの投稿を維持したい場合は、使用してください、そのハッシュ値11ed7f1、脱落したレコードを提出し、未使用の分岐点を取り、翻訳git branch <new-branch-name> 11ed7f1に新しい分岐命令とポイントを作成しますレコードを提出

$ git branch -av
* master 314b549 add main2.cpp

git branch pick 11ed7f1

$ git branch -av
* master 314b549 add main2.cpp
  pick   11ed7f1 add main2.cpp again
  

おすすめ

転載: www.cnblogs.com/milesgo517/p/10994171.html