簡體   English   中英

第二次合並沒有沖突

[英]no conflict on second time merging

我是git的新手。 我用“ myfile.txt”檢查了一個文件,其內容為

first commit in master.

使用git commit -a -m "first commit"在master分支中git commit -a -m "first commit"更改

第二步,我從主mysecondbranch分支創建了一個分支。 並添加第二行。

first commit in master.
**second commit in mysecondbranch.**

再次在mysecondbranchmysecondbranch更改

現在切換回master分支。 並添加了新內容

frst commit in master.
**second commit in newbranch.**

並將更改提交到master分支。

接下來,我想使用以下命令合並mysecondbranch中的更改:

git merge mysecondbranch

這次,正如預期的那樣,合並時存在沖突。

問題從這里開始,我放棄使用合並的更改

git reset HEAD myfile

再次嘗試合並,但是這次我很驚訝,沒有沖突,也沒有git diff結果

我得到的錯誤是fatal: commit your changes before you can merge.

當您發出

git reset HEAD myfile

您不會放棄合並的更改。 做一個

git status

重置后,您會看到您已撤消更改。 如果您想真正放棄合並中的更改,請執行

git reset --hard HEAD

通話后合並。

采用

git reset --hard master

代替

git reset HEAD myfile

放棄更改

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM