Git益智游戏 - 解决`拒绝非快进` [英] Git puzzler - Working around `denying non-fast-forward`

查看:180
本文介绍了Git益智游戏 - 解决`拒绝非快进`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我本地的git仓库中,我主要有:

In my local git repository, I had essentially:

* commit A
|
* commit B (master) (origin/master)

我做了一些修改,现在是:

I made some changes so it is now:

* commit A
|\
| * commit B (develop) (origin/master)
|
* commit C (master)

我想要Git回购(托管在beanstalkapp上。 com)将被更新以反映这一点,并且看起来像:

I would like the Git repo (hosted on beanstalkapp.com) to be updated to reflect this, and look like:

* commit A
|\
| * commit B (develop) (origin/develop)
|
* commit C (master) (origin/master)

我该怎么做? git push 失败,并且拒绝非快进refs / head / master 。我的解决办法是什么?

How can I do this? git push fails with denying non-fast-forward refs/head/master. What are my options to work around this?

我的回购并不是非常有组织,我想重新构建它。

My repo hasn't been very organized, and I'd like to refactor it once and for all.

推荐答案

git checkout master
git merge origin/master strategy=ours
git push origin master

'我们'的策略忽略了所有commit A B ,并进行假合并(仅限名义合并)。 git push 然后很高兴在旧的 origin / master 和新的 master 。

The 'ours' strategy ignores all changes made between commit A and B, and makes a "fake" merge (a merge in name only). git push then happily does a fast-forward commit between the old origin/master and the new master.

结果:

The result:

* commit A
|\
| * commit B (develop)
| |
* | commit C
| /
* commit D, but identical to C (master) (origin/master)

这篇关于Git益智游戏 - 解决`拒绝非快进`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆