使用Git合并文件

huangapple go评论85阅读模式
英文:

Merging files using git

问题

  1. 我有一个问题一直在尝试合并同一个文件,但来自不同分支,所以想象一下:
  2. number->”代表行号
  3. 文件(分支1

1->print("Hello world");
2->test();

  1. 文件(分支2

1->function1();

  1. 我希望合并的输出是这样的
  2. 合并文件

1->print("Hello world");
2->test();
3->function1();

  1. 我正在使用gitGitHub
英文:

i have a question i have been trying to merge the same file but from different branches so lets imagine:
"number->" stands for the line number

file(branch1)

  1. 1->print("Hello world");
  2. 2->test();

file(branch2)

  1. 1->function1();

i would like to output of the merge to be like this
mergedfile

  1. 1->print("Hello world");
  2. 2->test();
  3. 3->function1();

Im using git and github.

答案1

得分: 1

无法像你想象的那样强制 Git 合并文件。

我建议:

  1. git checkout branch1
  2. git merge --no-commit branch2
  3. # 自行审查合并的文件...
  4. git add 文件
  5. git commit
英文:

You cannot force GIT to merge files as you imagine.

I suggest to:

  1. git checkout branch1
  2. git merge --no-commit branch2
  3. # Review merged file on your own...
  4. git add file
  5. git commit

huangapple
  • 本文由 发表于 2023年3月7日 19:55:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/75661679.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定