Reset branch to different commit (Git)

How can I reset (hard or soft) my current branch to a different commit?

1 answer

0 vote
Colin Goudie Community Champion Nov 15, 2011

git reset --hard COMMIT_ID


git reset --hard 0f347f

With SourceTree you would probably right click on the commit and do a checkout (discard changed) or something

I know how I can do that on command line, but I want to avoid command line at all. BTW, the Reset toolbar button exists, but is disabled.

As Colin says, right-click a commit in the log and select 'Checkout'. You can also use the Checkout toolbar button / menu item and select an item from the list in the dialog.

I've tried, but Checkout just changes what working tree state I will have. It does not move my current branch to the selected commit. Is the Reset feature missing in SourceTree though a toolbar button with this name already exists?

'git reset' has many different modes, SourceTree uses the most common one which is to undo your working copy changes. Checkout effectively does 'git reset' followed by 'git checkout' for missing files.

You're clearly looking for 'git reset --hard' to move your branch pointer elsewhere. SourceTree doesn't support that yet.

Not just reset --hard, but also --soft and --mixed. All those move the branch pointer, but do different things with the index or working tree.

Suggest an answer

Log in or Join to answer
Community showcase
Maarten Cautreels
Posted Thursday in Off-topic

Friday Fun: What's your favourite beer/drink

As a Belgian, beer-lover and home brewer, beer is one of my great passions. I love the fact that with just a few ingredients (usually just water, hop and malt) you can create so many different tastes...

285 views 38 9
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot