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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

"Undoing commits" in sourcetree Edited

I know this question is everywhere online and almost everywhere has the solution, but each time I try a different solution I lose my work when switching branches or something. I figure this may be from the differences in command line vs. sourcetree's UI. Can someone help me with this scenario?

What I want to do: move the master to the head, delete the throwaway branch.
I don't care if the commits on the master branch are deleted.


https://gyazo.com/40b19c085f49132889964c1e6460352e

I made some changes to the project I was working on awhile back, but then decided I wanted to revert those changes. So I was left with the master a few commits up, and then I made a new commit after checking out the commit where the branch starts. What I wanted to do was move the master to the head, but some solutions require checking out master and making a new branch. I did just that, making a new branch called throwaway, but ironically that threw away my commit where the head is - not sure why. So now I am stuck with the throwaway branch there, and no progress toward moving master -> head.

Thanks a lot!

1 answer

0 votes
Mike Corsaro Atlassian Team Dec 05, 2018

Hello! So it seems there's some confusion as to what "HEAD" means. HEAD is a pointer to a commit, and in this case it's a pointer to that commit you switched to rather than the latest commit on a branch. Specifically, you're on a detached HEAD, which means any commits you make right now might get lost.

 

The easiest way to fix this is to create a new branch. This is probably what the "throwaway" is supposed to be. Once you make that new branch, switch back to "master" and then merge that previous branch into master. Once merged, do a push, and that "origin/master" and "origin/HEAD" indicator should now be back on the "Reverted to Controller" commit.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

4,406 views 4 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you