git SourceTree - 删除等待推送

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28990596/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 02:59:50  来源:igfitidea点击:

SourceTree - remove waiting pushes

gitpushcommitgit-commitatlassian-sourcetree

提问by teejay

How do I remove commits, waiting to be pushed to remote?

如何删除等待推送到远程的提交?

2 pushes waiting

2 推等待

My situation is, that those queued commits (changes) been already pushed (more bellow) and now the server refuses to accept those as they are behind the HEAD.

我的情况是,那些排队的提交(更改)已经被推送(更多内容),现在服务器拒绝接受那些在 HEAD 后面的提交。

I tried resetting to another commit, but when I go back to HEAD, pushes reappear again.

我尝试重置为另一个提交,但是当我回到 HEAD 时,再次出现推送。

Clicking Repository > Refresh Remote Status won't help, it actually added the 2nd waiting push :)

单击存储库> 刷新远程状态无济于事,它实际上添加了第二个等待推送:)

PS: I apologize for my terminology, I'm quite new to git.

PS:我为我的术语道歉,我对 git 很陌生。

.

.

Update 1

更新 1

Problems started when I were commiting feature2 to master branch. I don't have rights to commit there so it got stuck. Then I commited again to my personal branch, which was OK. Then I got one waiting commit, never to be pushed, even if I select the right (personal) branch when I click Push.

当我将 feature2 提交到 master 分支时,问题就开始了。我无权在那里提交,所以它被卡住了。然后我再次提交到我的个人分支,这很好。然后我得到了一个等待提交,永远不会被推送,即使我在单击推送时选择了正确的(个人)分支。

enter image description here

在此处输入图片说明

回答by R0MANARMY

Git commits form a commit graph. Branches are just named pointers to commits in that graph.

Git 提交形成一个提交图。分支只是指向该图中提交的命名指针。

Given that, your question can be restated as

鉴于此,您的问题可以重新表述为

My local masterbranch is pointing to a different commit than the remote masterbranch. How do I make my local masterbranch point to the same commit as the remote masterbranch?

我的本地分支指向与远程分支不同的提交。如何让我的本地master分支指向与远程master分支相同的提交?

There are two ways to accomplish this. Move the remote branch (git push) or move the local branch (git reset). As you said, you can't push to the remote masterbranch, so options 1 is off the table, that leaves option 2.

有两种方法可以实现这一点。移动远程分支 ( git push) 或移动本地分支 ( git reset)。正如你所说,你不能推送到远程分支,所以选项 1 不在表中,剩下选项 2。

Note that the resetoperates on the currently checkout branch1so you'll first want to make sure you are currently on the masterbranch and then move that branch to the same commit as the remote masterbranch.

请注意,reset操作在当前结帐分支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

Now that masterand origin/masterare on the same commit, there should be no commits to push.

现在masterorigin/master在同一个提交上,应该没有提交要推送。



  1. resetoperates on the current HEAD, but for the sake of this explanation it's easier to think of of it as operating on branches. For more information see this question: What is HEAD in Git?.
  1. reset在当前 HEAD 上操作,但为了便于说明,更容易将其视为在分支上操作。有关更多信息,请参阅此问题:Git 中的 HEAD 是什么?.

回答by facundofarias

Have you tried by doing: git reset --hard HEAD~1? In this way, you will have the head again on your local repo. Otherwise, I've seen a funny page that might be useful: http://ibrokegit.com/

你有没有试过这样做:git reset --hard HEAD~1?通过这种方式,您将再次拥有本地存储库的头。否则,我看到了一个可能有用的有趣页面:http: //ibrokegit.com/

Most of the times, this things should be solved by using the command line, instead of the GUI (in this case, SourceTree).

大多数情况下,应该使用命令行而不是 GUI(在本例中为 SourceTree)来解决这些问题。

Hope it helps!

希望能帮助到你!