我從我的項目中檢查了特定的提交,並從那裏繼續,希望在提交之後的更改將被刪除,並且我檢查到的提交將是新的頭。我做出了新的改變,但我無法推動它們。我還是新來的git。如何從特定提交中繼續項目並修復HEAD分離問題?
我所做的是:
- git的結帳commit_hash
- 編輯項目
- git的承諾-m 「新變化」
- 混帳推-u起源主
我得到了:
To https://github.com/myusername/project.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/miloradsimic/ISA16.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
當我輸入 git的狀態我:
HEAD detached from 506f0ec nothing to commit, working directory clean
我改變了項目的層次結構,在頭承諾,所以我要讓它回到以前的狀態。我不想將它與頭部合併。
我這樣做(簡單的方法,不專業): 我曾在一個文件夾項目的變化,沒有定位在頭上。 我將頭部提交下載到新文件夾中,並將我對該文件夾的更改複製到文件夾中的所有文件(git文件除外)。刪除了不必要的文件。添加了所有更改,提交併推送。
感謝,米洛拉德·西米奇
我創建了新的分支,但現在我有2個分支,master和dev。 我可以作爲最終結果只有主分支與來自curent dev的數據嗎? –
是的,你可以。我猜'master'是你的'Default branch',所以不要刪除'default'分支。你想現在用'dev'分支替換你的'master'分支嗎? –
我有要從主服務器刪除的文件。我可以再次去掌握頭腦,並在下一次提交中刪除我不需要的遠程文件? –