gpt4 book ai didi

git - 如何在冲突时将文件拆分为我们的和他们的

转载 作者:行者123 更新时间:2023-12-02 14:55:22 25 4
gpt4 key购买 nike

我有办法获得 2 个文件副本,第一个包含远程内容,第二个包含本地内容

最佳答案

我不认为有一个 git 选项可以将文件的两个版本保存在两个副本中。

但您可以使用以下命令轻松实现此目标:

git merge the_branch
git checkout --theirs -- path/to/file ; mv path/to/file path/to/file.theirs
git checkout --ours -- path/to/file ; mv path/to/file path/to/file.ours
git checkout -m -- path/to/file

最后你有三个文件:

  • file.theirs,以及他们的版本;
  • file.ours,你的版本;
  • 文件,包含版本和冲突标记。

关于git - 如何在冲突时将文件拆分为我们的和他们的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53246498/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com