Return to console using sourcetree

I accidentally pressed a function branch on a remote master. Now I want to return the wizard to the previous commit. When I select "Revert current branch to this commit", only the local branch is returned, and since the remote master is 55 ahead (randomly pressing), I cannot push the newly restored local master to the remote computer.

When I studied this problem in SO and Google, I found that many use force push using the command line. But since I use the Source Tree, I would like to find a way that actually uses the Source Tree.

I also found a reinstallation option, but I cannot find a walkthrough.

Any ideas?

+7
git atlassian-sourcetree
source share
3 answers

When you push a commit, the safest way to get it back (instead of forcibly pressing -f) is to use the revert function, so a new commit is created on top of your previous commit.

This can be done using Sourcetree by right-clicking on the commit you want to return and selecting "Reverse commit ...".

enter image description here

You will need to do this for each commit you want to return in the reverse order.

+8
source share

Sourcetree does not provide you with the -f flag: https://answers.atlassian.com/questions/54469/how-do-i-perform-a-forced-push-push-f-from-sourcetree

Thus, the only way to return the remote back to its original state is git revert , each of which is committed in the reverse order.

Assuming the remote is removed on commit A , and you clicked on the commit of your commit objects B , C and D , you should

 git revert D git revert C git revert B git push 

Clicking will work just fine since you are not modifying the transferred history, but instead clicking on a new set of changes.

If you want to shorten your call sequence to one commit, you can do

 git rebase -i origin/master 

and select each of your revert to be squashed . Then your push will contain only one latch, which returns D , C and B at a time.

0
source share

The best way to do this is with the Reset <branch> to this commit option shown in the image below.

Reset for previous commit

A pop-up window will appear in which you can choose which reset code mode you want to select. [See below] Choose the mode of reset

Note: This is not exactly a code reversal, but it completely removes your commit from the remote device and makes it cleaner.

0
source share

All Articles