我是一個新手混帳。 我正在研究一個涉及大量代碼移動的分支,包括刪除舊的和添加的新文件。因此,我決定在實際合併之前做一個幹運行的git合併:如何`git reset`後'git合併 - 無提交 - 無-ff`
我跑git merge --no-commit --no-ff <myBranchName>
。在我運行這個之後,它給我帶來了一些衝突。然後我做了git的狀態和結果是:
My-Macbook-pro:[master] $ git status
# On branch master
# You have unmerged paths.
# (fix conflicts and run "git commit")
#
# Changes to be committed:
# modified: common/TP.php
# deleted: common/model/Job/Request.php
# new file: common/DP.php
#
# Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark resolution)
#
# both modified: .gitignore
# both added: build/release/current/production.sql
# deleted by them: common/Service/DFPASPAdapter.php
# both modified: common/Ze.php
# deleted by them: common/model/provider/DFPASP.php
然後撤消git add
(即發生因git merge
幹運行的),我跑git reset HEAD
。但後來我意識到/瞭解到爲了回到主分支在合併前的階段(即完全與承諾主人相同),我需要運行git reset --hard HEAD
在我運行硬復位後,git status
顯示以下內容:
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# build/release/current/upgrade.php
# common/F1.php
# common/F2.php
# common/F3.php
nothing added to commit but untracked files present (use "git add" to track)
上述文件F1,F2,F3和upgrade.php被添加到我正在處理的分支中。我希望git reset --hard HEAD
將使master
分支忘記與我試圖合併的分支有關的任何事情(幹運行)。
這是可能的東西嗎? 這個概念中是否有我缺少的東西?我只剩下手動刪除文件的唯一選擇了嗎? 讓我更瞭解更多的任何幫助將會很棒! 謝謝!