如何删除等待推送到远程的提交?
我的情况是,那些排队的提交(更改)已经被推送(更多下文),现在服务器拒绝接受它们,因为它们在 HEAD 后面。
我尝试重置为另一个提交,但是当我返回 HEAD 时,推送再次出现。
- SourceTree - undo unpushed commits
- https://answers.atlassian.com/questions/153791/how-should-i-remove-push-commit-from-sourcetree
点击 Repository > Refresh Remote Status 没有帮助,它实际上添加了第二次等待推送:)
PS:我为我的术语道歉,我是 git 的新手。
.
更新 1
当我将 feature2 提交到 master 分支时,问题开始了。我无权在那里提交,所以它卡住了。然后我再次提交到我的个人分支机构,这没问题。然后我得到一个等待提交,永远不会被推送,即使我在单击“推送”时选择了正确的(个人)分支也是如此。
最佳答案
Git 提交形成一个提交图。分支只是指向该图中提交的命名指针。
鉴于此,您的问题可以重述为
My local master branch is pointing to a different commit than the remote master branch. How do I make my local master branch point to the same commit as the remote master branch?
有两种方法可以做到这一点。移动远程分支(git push
)或
移动本地分支 ( git reset
)。正如您所说,您无法推送到远程 master 分支,因此选项 1 不在考虑范围内,剩下选项 2。
请注意,reset
在当前 checkout 分支1 上运行,因此您首先要确保您当前在 master分支,然后将该分支移动到与远程 master 分支相同的提交。
git checkout master <--- make sure you're on the master branch
git reset --hard origin/master <--- put your master branch on the same commit as origin/master
现在 master 和 origin/master 在同一个提交上,应该没有要推送的提交。
reset
对当前 HEAD 进行操作,但为了便于解释,将其视为对分支进行操作会更容易。有关详细信息,请参阅此问题:What is HEAD in Git? .
关于git - SourceTree - 删除等待推送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28990596/