0

我创建了一个分支“test1”,更改了一个文件,并且不将它合并回 master。我忘记了一个星期的考试。自从那个 test1 分支以来,我对 master 进行了很多更改。

但是,然后我决定我仍然喜欢我所做的 test1 中的一个功能,即我更改的单个文件。

当我将分支 test1 合并到 master 时,合并了什么?只是 test1 文件?我不想用旧的 test1 分支文件覆盖我所有的新主文件(除了我更改的一个文件)。

4

2 回答 2

2

默认的合并策略,recursive将找到共同的祖先,并尝试将分支中发生的更改应用test1到当前分支(即master)。因此,该命令git merge test1将保留分支中发生的更改master,并应用您在test分支上执行的一项更改。

不要害怕!如果事情确实以某种方式出错(例如,存在冲突但您错误地解决了它),git 可以很容易地将分支重置回较早的提交并再次尝试合并。

于 2015-04-17T22:56:48.723 回答
0

You'll want to ensure you check out the branch you wish to merge into (the master branch in your case), and then run the git merge command.

git checkout master
git merge test1

Also check the 'Basic Merging' section on the official documentation here

于 2015-04-17T23:02:59.070 回答