簡體   English   中英

git merge --no-commit --no-ff`后如何`git reset`

[英]How to `git reset` After `git merge --no-commit --no-ff`

我是git的新手。 我在一個分支中工作,涉及許多代碼的移動,包括刪除舊文件和添加新文件。 因此,我決定在實際合並之前先進行git merge的試運行:

我跑了git merge --no-commit --no-ff <myBranchName> 運行此命令后,它顯示了一些沖突。 然后我做了git status,結果是:

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 dry run而發生),我運行了git reset HEAD 但是后來我意識到/了解到為了回到合並之前master分支所在的階段(即與提交給master的對象完全相同),我將需要運行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分支忘記與我嘗試合並(空運行)的分支有關的任何內容。

這有可能嗎? 我在概念中缺少什么嗎? 我是否只有手動刪除文件的選項? 使我了解更多的任何幫助都將非常有用! 謝謝!

git不知道不在索引中的文件。 要刪除與當前分支無關的文件,包括非跟蹤文件,請運行

git clean -fd .

暫無
暫無

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

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