-1

愚かさを通して、大きなファイルの唯一のバージョンはマージしようとすることです。つまり、次のような行がたくさん含まれています。

<<<<<<< HEAD        double[] p1 = ...
                    double[] p2 = ...
=======         double[] p1 = ...
                double[] p2 = ...
>>>>>>> origin/foo

それぞれを編集せずに、常に選択して、これらを取り除くにはどうすればよいHEADですか?

マージといくつかの愚かなコマンドにより、元のHEADの痕跡がなくなりましたが、幸いなことにgitreflogを使用してマージ前の位置を見つけることができました。

4

2 に答える 2

1

常にHEADを選択したい場合は、merge strategyと呼ばれるを探していますours

行うgit merge -s ours <branch-to-merge>

マージに関するgitヘルプの引用:

マージ戦略マージメカニズム(git-mergeおよびgit-pullコマンド)を使用すると、バックエンドのマージ戦略を-sオプションで選択できます。一部の戦略では、独自のオプションを使用することもできます。これは、git-mergeやgit-pullに-X引数を指定することで渡すことができます。

   recursive
       This can only resolve two heads using a 3-way merge algorithm. When there is more than one common ancestor that can be used
       for 3-way merge, it creates a merged tree of the common ancestors and uses that as the reference tree for the 3-way merge.
       This has been reported to result in fewer merge conflicts without causing mis-merges by tests done on actual merge commits
       taken from Linux 2.6 kernel development history. Additionally this can detect and handle merges involving renames. This is
       the default merge strategy when pulling or merging one branch.

       The recursive strategy can take the following options:

       ours
           This option forces conflicting hunks to be auto-resolved cleanly by favoring our version. Changes from the other tree
           that do not conflict with our side are reflected to the merge result.

           This should not be confused with the ours merge strategy, which does not even look at what the other tree contains at
           all. It discards everything the other tree did, declaring our history contains all that happened in it.

       theirs
           This is opposite of ours.

   ours
       This resolves any number of heads, but the resulting tree of the merge is always that of the current branch head,
       effectively ignoring all changes from all other branches. It is meant to be used to supersede old development history of
       side branches. Note that this is different from the -Xours option to the recursive merge strategy.

これらはリストされている戦略の一部です。git help mergeそれらの多くを探すために使用します。

于 2012-07-31T11:53:00.043 に答える
0

-X ignore-space-changeコマンドラインに渡すことで、マージ中のスペースの変更を無視できます。これは、でも機能しgit rebaseます。

于 2012-07-31T11:17:51.580 に答える