Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/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_Version Control_Bitbucket - Fatal编程技术网

如何在GIT推送过程中忽略远程更改?

如何在GIT推送过程中忽略远程更改?,git,version-control,bitbucket,Git,Version Control,Bitbucket,在GIT上推动项目时,我遇到了以下问题 按下该按钮,我将获得此错误消息: $ git push origin master To https://bitbucket.org/MyAccount/my-project.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://MyAccount@bitbucket.org/MyAccount/my-pr

在GIT上推动项目时,我遇到了以下问题

按下该按钮,我将获得此错误消息:

$ git push origin master
To https://bitbucket.org/MyAccount/my-project.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://MyAccount@bitbucket.org/MyAccount/my-projec.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
所以,如果我做了错误的断言,请纠正我的错误,在我的远程存储库中有一些我没有在本地存储库中进行的更改,它建议我执行拉取以获得这些更改

这对我来说是一个问题,因为本地版本是我的应用程序的最后一个最终版本,我不能冒险将旧的和错误的(或由其他人制作的)内容从远程存储库中覆盖


我是否可以指定在不考虑远程更改的情况下推送本地内容?或者我如何检查上次本地提交和远程内容之间的差异?

是的,正如您所理解的,这是因为远程
master
分支有新版本(可能是您的同事推送的)。你不能忽略新版本,除非你用力推,这会导致新版本丢失

您应该将新版本从远程拉到本地,并在新版本的顶部重新设置未推送提交的基础,并将冲突文件保留为本地版本(如果git拉过程中存在冲突,您可以使用该命令)

git pull origin master --rebase -X theirs
您可以使用跟踪分支来检查remote是否有新版本
master
分支通常跟踪到
origin/master
(您可以通过
git branch–vv
进行检查)。然后您可以使用
git status
,git将在本地主分支和远程分支之间进行比较。

可能重复的