Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SourceTree - remove waiting pushes

Tags:

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

2 pushes waiting

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.

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

  • SourceTree - undo unpushed commits
  • https://answers.atlassian.com/questions/153791/how-should-i-remove-push-commit-from-sourcetree

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.

.

Update 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.

enter image description here

like image 600
teejay Avatar asked Mar 11 '15 15:03

teejay


People also ask

How do I get rid of waiting push in Sourcetree?

To remove the commit without changing any source code, you need to perform a "mixed" reset. Right click on the last "good" commit (this will probably be origin/master ). Select "Reset current branch to this commit." In the resulting dialog, select "Mixed..." from the drop down and click OK.

How do I revert pushed changes in Sourcetree?

When you push a commit, the safest way to revert it (rather than forcing the push with -f) is to use the revert function, so a new commit is created on top of your previous commit. This is possible to do using Sourcetree, right clicking in the commit that you want to revert, and selecting "Reverse commit...".

How do I remove uncommitted changes in Sourcetree?

On SourceTree for Windows, right click the files you want to discard (in the Working Copy Changes list), and choose Discard. On git, you'd simply do: git reset --hard to discard changes made to versioned files; git clean -xdf to erase new (untracked) files, including ignored ones (the x option).


2 Answers

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

Given that, your question can be restated as

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?

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 master branch, so options 1 is off the table, that leaves option 2.

Note that the reset operates on the currently checkout branch1 so you'll first want to make sure you are currently on the master branch and then move that branch to the same commit as the remote master branch.

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 master and origin/master are on the same commit, there should be no commits to push.


  1. reset operates 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? .
like image 184
Roman Avatar answered Oct 21 '22 20:10

Roman


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/

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

Hope it helps!

like image 42
facundofarias Avatar answered Oct 21 '22 20:10

facundofarias