Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 如何将主分支推送到另一个分支?_Git - Fatal编程技术网

Git 如何将主分支推送到另一个分支?

Git 如何将主分支推送到另一个分支?,git,Git,我怎样才能把我的主分支推到我的旧分支 我正在尝试使用: git-push-originmaster:我的分支,但我一直得到一个错误 ! [rejected] master -> my_branch (non-fast-forward) error: failed to push some refs to hint: Updates were rejected because the tip of your current branch is behind hint: its

我怎样才能把我的主分支推到我的旧分支

我正在尝试使用:

git-push-originmaster:我的分支,但我一直得到一个错误

 ! [rejected]        master -> my_branch (non-fast-forward)
error: failed to push some refs to
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

我对使用Git还是新手。我试图使用rebase,但我很难理解它。有人能帮我吗。非常感谢您的帮助。

您要推送到的分支已经提交了xou在本地没有的内容

如果您想拥有所有提交,您可以先执行
git pull my_branch origin
合并它们(并解决可能的冲突)

如果要覆盖上游分支,可以使用git push-f origin master:my_branch


强制推送将覆盖来自其他用户的更改。如果您只想在没有其他用户在这段时间内推动git-push--force与lease origin master:my_branch分支时执行此操作,则可以使用该分支执行此操作。

是否要将分支中的更改合并到主分支?或者主分支更改为您的分支?我想将主分支推送到我的分支,以便过时的分支已经更新。这是一种非常奇怪的更新分支的方法。正常的程序是在本地将master合并(或重新设置基址)到“your branch”中,然后推送您的分支。编辑:如果您不关心“your branch”的内容,那么强制推送(如下所示)可以正常工作。但在这一点上,你最好删除“你的分支”并用masterhi创建一个新分支。先生,我试着使用rebase,我确实很难做到这一点。对不起,先生。
git-push——强制租赁原始主机:my_branch
使用此命令,过时的分支是否会像主机一样更新?强制推送(
-f
)将完全覆盖分支。但是,如果您不知道,其他用户已推送到该分支,则这可能是一个问题<代码>--force with lease在这种情况下将失败。我是唯一一个使用过时分支的人。我只想让那个旧分支像主分支一样。然后使用git push-f origin master:my_branch。谢谢您,先生。我确实试过了,我真的很难过。对不起,先生。