Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.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
错误:无法将某些引用推送到';https://github.com/XXXXXXXXX.com_Git_Github_Push_Git Push_Git Pull - Fatal编程技术网

错误:无法将某些引用推送到';https://github.com/XXXXXXXXX.com

错误:无法将某些引用推送到';https://github.com/XXXXXXXXX.com,git,github,push,git-push,git-pull,Git,Github,Push,Git Push,Git Pull,今天我第一次使用github,我已经检查了其他答案,其中只有一个似乎有效,那就是使用“git push origin master--force”,但这样做会删除所有其他提交。因此,任何人都可以告诉我这个问题的解决方案。如果您的本地分支位于远程分支的后面,并且在其上有一些提交,那么您可以通过运行以下命令来解决问题 $git拉入原始主机--重新基址 $git推送原始主机 NB:如果只运行git pull而不运行--rebase,那么它将添加一个您可能不想要的合并提交。如果您的本地分支位于远程分支

今天我第一次使用github,我已经检查了其他答案,其中只有一个似乎有效,那就是使用“git push origin master--force”,但这样做会删除所有其他提交。因此,任何人都可以告诉我这个问题的解决方案。

如果您的
本地
分支位于
远程
分支的后面,并且在其上有一些提交,那么您可以通过运行以下命令来解决问题

$git拉入原始主机--重新基址
$git推送原始主机

NB:如果只运行
git pull
而不运行
--rebase
,那么它将添加一个您可能不想要的
合并
提交。

如果您的
本地
分支位于
远程
分支之后,并且在其上有一些提交,然后,您可以通过运行以下命令来解决问题

$git拉入原始主机--重新基址
$git推送原始主机

NB:如果您只运行
git pull
而不运行
--rebase
,那么它将添加一个您可能不想要的
合并
提交。

只需在终端中运行此代码即可

$ git push -u origin master
To https://github.com/XXXXXXXXX.com/FirstRepo.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/XXXXXXXXX.com/FirstRepo.git'
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 pull origin master --allow-unrelated-histories

只需在终端中运行此代码

$ git push -u origin master
To https://github.com/XXXXXXXXX.com/FirstRepo.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/XXXXXXXXX.com/FirstRepo.git'
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 pull origin master --allow-unrelated-histories

你先拉了吗?你可以用git pull来获取远程更改,然后你的推应该可以工作是的,我在推之前做了,但它仍然给出了相同的提示。但是在提交过程中,它显示为“create mode 100644 textfile.txt”,如果你先
git pull
,听起来好像出了什么问题。发布更多细节。展示您的步骤,展示输出,然后我们也许可以帮助您完成它。目前,任何人都能给出的最好的建议是“先使用git pull”,然后使用push。你可以试试下面的帖子:你先使用git pull吗?你可以使用git pull来获取远程更改,然后你的push应该可以工作是的,我在使用push之前就这样做了,但它仍然给出了相同的提示。但是在提交过程中,它会像这样显示“create mode 100644 textfile.txt”如果你先做了
git pull
,听起来好像出了什么问题。发布更多详细信息。展示你的步骤,展示输出,然后也许我们可以帮助你完成。目前,任何人都能给出的最好建议是“先使用
git pull
”,然后再推。你可以尝试以下帖子: