GIT 替换分支的内容

发布于 2024-12-29 09:44:47 字数 373 浏览 1 评论 0原文

我有一个包含以下分支的裸存储库设置:

dev
*master
stage
prod

我已将其克隆到工作副本并发出以下命令:

git checkout -b stage remotes/origin/stage
git checkout -b dev remotes/origin/dev

我需要做的是将暂存分支的全部内容推送到我的开发分支中。基本上,这是第一次设置,我首先将生产代码推送到暂存分支(工作完美),现在我将暂存代码推送到开发分支。

我遇到的问题是二进制文件的合并冲突。我如何告诉 git 甚至不要查看合并冲突,而是直接将 stage 分支的内容复制到 dev 分支中?

I've got a bare repo setup with the following branches:

dev
*master
stage
prod

I've cloned this to a working copy and issued the following commands:

git checkout -b stage remotes/origin/stage
git checkout -b dev remotes/origin/dev

What I need to do is push the entire contents of my staging branch into my dev branch. Basically, this is a first-time setup, and I started with pushing production code into a staging branch (worked flawlessly) and now I'm pushing my staging code into the dev branch.

The problem I'm encountering is a merge conflict on binary files. How do I tell git to not even LOOK at merge-conflicts, and instead just straight up copy over the contents of the stage branch into the dev branch?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

桃扇骨 2025-01-05 09:44:47

听起来像 --s oursmerge 选项正是您所需要的。

http://book.git-scm.com/5_advanced_branching_and_merging.html

Sounds like --s ours option of merge is right what you need.

http://book.git-scm.com/5_advanced_branching_and_merging.html

自由如风 2025-01-05 09:44:47

您有几个选择:

  1. 与“我们的”策略合并
  2. 正常合并,然后使用 'git checkout HEAD^ --' 修改合并提交。
  3. 使用“git reset --hard staging”将开发分支重置为指向暂存,
  4. 不要合并,而只是在“git checkout staging --”之后提交暂存中的内容。

选项 1 和 3 可能是最好的。您需要了解 DAG(谷歌“计算机科学家的 git”)。

我们使用以下工作流程:https://plus.google.com/109096274754593704906/posts/R4qkeyRadLR

这对我们来说非常好。

You have a few options:

  1. Merge with the "ours" strategy
  2. Merge normally and then amend the merge commit after with 'git checkout HEAD^ -- .'
  3. Reset the dev branch to point to staging with 'git reset --hard staging'
  4. Don't merge but just commit what's in staging after 'git checkout staging -- .'

Options 1 and 3 are probably best. You need to know the DAG (google "git for computer scientist").

We use this work flow: https://plus.google.com/109096274754593704906/posts/R4qkeyRadLR

It's been very good for us.

无声静候 2025-01-05 09:44:47

决定修复它的最简单方法是这样做:

克隆存储库两次,一次复制到开发文件夹中,一次复制到阶段文件夹中
然后

cd dev
git rm -rf *
git commit -a -m "take that n00b repo!"
git push
cp -r ../stage/* .
git add *
git commit -a -m "how you like dem apples??"
git push

不优雅,但它完成了工作,并且比处理 git 的合并冲突要少得多。

Decided the simplest way to fix it was to do this:

clone the repo twice, once into a dev folder once into a stage folder
then

cd dev
git rm -rf *
git commit -a -m "take that n00b repo!"
git push
cp -r ../stage/* .
git add *
git commit -a -m "how you like dem apples??"
git push

Inelegant but it got the job done, and was a lot less painful than dealing with git's merge conflicts.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文