1

私は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、 を実行しまし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ました(ドライラン)。

これは可能なことですか?コンセプトに欠けているものはありますか?そして、ファイルを手動で削除する唯一のオプションが残っていますか? 私がもっと理解できるようにするための助けは素晴らしいでしょう!ありがとう!

4

1 に答える 1

1

git は、インデックスにないファイルについて知りません。追跡されていないものを含め、現在のブランチに関係のないファイルを削除するには、次を実行します

git clean -fd .
于 2013-06-21T22:56:15.060 に答える