【发布时间】:2020-10-19 23:29:04
【问题描述】:
我的原主和本地主的分歧如下。我想忽略 origin/master 中的更改,并能够将我的本地更改推送到 origin master。我做了 git pull ,然后是 git stash 并尝试推送,但这没有帮助。我不想创建新的提交并将更改从原始主机合并到我的本地主机。
[~/Documents/projectRepo]$ git status *[master]
On branch master
Your branch and 'origin/master' have diverged,
and have 40 and 1 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)
Unmerged paths:
(use "git add/rm <file>..." as appropriate to mark resolution)
deleted by us: file1.json
deleted by us: file2.json
no changes added to commit (use "git add" and/or "git commit -a")
当我在不拉的情况下强制推动时,我得到了这个:
git push -f origin master
Total 0 (delta 0), reused 0 (delta 0)
remote: error: GH003: Sorry, force-pushing to master is not allowed.
To ssh://github.com/zack/projectRepo.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://github.com/zack/projectRepo.git'
【问题讨论】:
-
您目前处于不完整的合并中。您必须完成或中止合并,然后才能执行任何其他操作(至少在此工作树中)。
-
听起来您想强制推送您的更改以消除 origin/master 中的其他更改。但相反,您做了一个尝试合并这些更改的拉动。首先中止合并,然后确保你的分支是你想要的样子,然后强制推送它,用你的 master 版本替换 origin/master。
-
我更新了有关强制推送的详细信息的问题。它失败了,因为我不允许强制推送到 master
标签: git version-control version git-rebase git-merge-conflict