Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,454
Community Members
 
Community Events
184
Community Groups

revert origin/master to my local master

I've pushed a few commits to origin/master instead of side branch. I reverted my local master to the commit I want. Obviously I can't pull and then push because that would bring in undesired changes. I can't push straight away either, because my local branch is behind a few commits. Now how can I push it to origin and overwrite it?

Thanks,

Mav

4 answers

1 vote
Tim Crall
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Sep 04, 2015

At the command line: git push -f

I'm not sure if there's a way to do it from SourceTree - I'm not seeing one right off hand.  

Use that command very judiciously, though.  If anyone else has pulled the bad commits on to their local repositories, you would be better off reverting the commits rather than "deleting" them.

Also it is possible that your remote may be configured to reject force pushes, in which case this won't work.

 

Johannes Kilian
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Sep 13, 2015

"Forced push" is not accessible in windows version of Sourcetree - see: https://jira.atlassian.com/browse/SRCTREEWIN-338

Tim Crall
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Sep 14, 2015

You should be able to do it from Git Bash (command line), though, if it hasn't been disabled on your remote. Again, you should use it judiciously, if at all.

0 votes
Julius Davies _bit-booster_com_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Feb 23, 2019

To push any arbitrary commit-id to origin/master from the command-line, here's the command (this forces origin/master to become the exact commit-id specified):

 

git push --force origin <commit-id>:refs/heads/master

 

For example:

git push --force origin 6fe08acd2f:refs/heads/master

I am not fan of git... but no option and forced to use...

 

I have same question how do revert my change or change committed file without creating another change list

Thank you Tim,

I'll investigate further.

Tim Crall
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Sep 08, 2015

Also note that in Git there is an important difference between the "reset" command and the "revert" command. The reset command moves the HEAD back to a previous commit. The revert command creates a new commit on the end of a branch that undoes the changes made by a specific commit (without actually removing that commit from the graph, therefore avoiding rewriting history).

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events