[英]git detach head in branch & merge
I was learning some git related topics and commands, this scenario occurred when i was using combination of git and GitHub features, using git push
and changing file at github at the same time, I have created 2 branches ( jsfirst
and imagegallery
) Just want to了解出了什么問題,我正在嘗試分析並打算在重要項目中不再重復
編輯為什么564903c (imagegallery) Image gallery
分支在圖形視圖中斷開連接?
HEAD@{0}, HEAD@{1}, HEAD@{2}, HEAD@{3}
是什么意思?
git git log --all --decorate --oneline --graph
命令
* 76ebb92 (HEAD -> master) Merge branches 'master' and 'master' of https://github.com/sometest/test
|\
| * 4f264fe (origin/master) Created CONTRIBUTING.md
| * 1159fe3 Merge pull request #3 from sometest/code_of_conduct-patch-2
| |\
| | * a7184f0 (origin/code_of_conduct-patch-2) Updated code of conduct
| |/
| * 4369922 Merge pull request #2 from sometest/code_of_conduct-patch-1
| |\
| | * 1893331 (origin/code_of_conduct-patch-1) Created CODE_OF_CONDUCT.md
| |/
| * b3fbde0 Created .gitignore
| * 6275e91 Merge pull request #1 from sometest/add-license-1
| |\
| | * 38d02c5 (origin/add-license-1) Create LICENSE
| |/
* | cc0cdad (jsfirst) Silly story
* | a52170c Using events in JS
* | c271cdd Added number guessing game
* | 493a155 Learned basic of JS
|/
| * 564903c (imagegallery) Image gallery
|/
* 25266ce first commit
git reflog
命令的 Output
76ebb92 (HEAD -> master) HEAD@{0}: reset: moving to HEAD
76ebb92 (HEAD -> master) HEAD@{1}: checkout: moving from 564903c3078ffdbdbd43bceb3da3495daddf82da to master
564903c (imagegallery) HEAD@{2}: checkout: moving from master to 564903c
76ebb92 (HEAD -> master) HEAD@{3}: checkout: moving from imagegallery to master
564903c (imagegallery) HEAD@{4}: checkout: moving from master to imagegallery
76ebb92 (HEAD -> master) HEAD@{5}: pull: Merge made by the 'recursive' strategy.
cc0cdad (jsfirst) HEAD@{6}: checkout: moving from imagegallery to master
564903c (imagegallery) HEAD@{7}: checkout: moving from master to imagegallery
cc0cdad (jsfirst) HEAD@{8}: reset: moving to cc0cdad
25266ce HEAD@{9}: checkout: moving from imagegallery to master
564903c (imagegallery) HEAD@{10}: checkout: moving from master to imagegallery
25266ce HEAD@{11}: checkout: moving from imagegallery to master
564903c (imagegallery) HEAD@{12}: checkout: moving from master to imagegallery
25266ce HEAD@{13}: checkout: moving from jsfirst to master
cc0cdad (jsfirst) HEAD@{14}: checkout: moving from imagegallery to jsfirst
564903c (imagegallery) HEAD@{15}: commit: Image gallery
25266ce HEAD@{16}: checkout: moving from master to imagegallery
25266ce HEAD@{17}: checkout: moving from jsfirst to master
cc0cdad (jsfirst) HEAD@{18}: commit: Silly story
a52170c HEAD@{19}: checkout: moving from master to jsfirst
25266ce HEAD@{20}: checkout: moving from jsfirst to master
a52170c HEAD@{21}: commit: Using events in JS
c271cdd HEAD@{22}: commit: Added number guessing game
493a155 HEAD@{23}: commit: Learned basic of JS
25266ce HEAD@{24}: checkout: moving from master to jsfirst
25266ce HEAD@{25}: commit (initial): first commit
Git 命令歷史
4221 git init
4222 git add README.md
4223 git commit -m "first commit"
4224 git remote add origin https://github.com/sometest/sometest.git
4225 git push -u origin master
4233 git checkout -b jsfirst
4235 git add chapter-1/hello.html
4236 git add README.md
4238 git commit -m "Learned basic of JS"
4241 git add chapter-1/numberguessinggame.html
4242 git commit -m "Added number guessing game"
4247 git add chapter-1/basic2/*
4249 git commit -m "Using events in JS"
4258 git add assessment-1/sillystorygenerator/*
4259 git commit -m "Silly story"
4262 git checkout master
4265 git add assessment-1/imagegallery/*
4266 git reset assessment-1/imagegallery
4270 git checkout -b imagegallery
4273 git add assessment-1/imagegallery
4274 git commit -m "Image gallery" .
4280 git checkout jsfirst
4284 git checkout master
4285 git merge --squash jsfirst
4287 git checkout imagegallery
4296 git merge --squash imagegallery
4297 git checkout master
4298 git merge --squash imagegallery
4305 git merge --squash imagegallery
4312 git reset --hard cc0cdad
4319 git checkout imagegallery
4323 git checkout master
4326 git pull
4333 git checkout imagegallery
4342 git checkout master
4343 git merge --squash imagegallery
4345 git merge imagegallery
4366* git chekout 564903c
4371* git commit -a -m "Image Gallery"
4372* git checkout master
4376* git commit -a -m "Image Gallery Detach HEAD"
4379* git reset --hard\n
我發現唯一值得回答的事情(因為這是唯一的問題)是:
HEAD@{0}
,HEAD@{1}
,HEAD@{2}
,HEAD@{3}
是什么意思?
HEAD@{n}
表示當前HEAD
之前的n
次提交。 因此, HEAD@{1}
意味着在HEAD
之前提交一次。 您還可以使用@~n
作為上述符號的簡寫(即,使用@~n
代替HEAD~n
來簡化事情)。
為什么 564903c (imagegallery) 圖像庫分支在圖形視圖中斷開連接?
您需要 state 您對提供的說明/命令的期望,然后才會清楚。 您提供的數據量在 go 中需要讀取很多。 沒有人有時間通過如此大量的命令來 go (不是指責你,而是陳述一個真實的案例)。 你需要對事情有點具體(更多內容見下文)。
我有一個建議給你,當你在這里發布問題時,只需要求其他人復制你的回購的當前 state。 這將意味着盡可能少的冗余指令。 例如,這個部分:
4319 git checkout imagegallery
4323 git checkout master
4326 git pull
4333 git checkout imagegallery
4342 git checkout master
包含冗余指令。 您可以僅使用git checkout master
、 git pull
和git checkout imagegallery
來完成此部分。 此外,在執行push
時不需要使用-u
,尤其是在執行git push origin <branch-name>
時。
順便說一句,您可能想查看Git提供的關於 Git 最終用戶面臨的各種常見問題的常見問題解答。 可能會幫助你一點:)
最好的
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.