How to recover from making changes in master instead of development branches?

I've been using sourcetree with gitflow, my first steps with these tools.

In error I made and commited changes in the master branch which is now 'ahead' of the develop branch.

By ahead I simply mean that the files listed under master have changes in them that have never been in Develop - hence I am worried that if I now develop a feature branch from develop I am going to be doing so on a version that is less developed than the master and risk losing those changes when develop later gets merged to master on completing a new release.

The changes I made were good and I want to preserve them, and get back to creating new features as branches from the development branch, later merging them into the master as new releases.

What is the best way to get things back on track?

1 answer

1 accepted

I think you could:

  1. Checkout your development branch.
  2. Merge master to dev. Resolve conflicts if any.
  3. commit changes to dev branch (now containing changes from master).

Thanks Alex,

I am unclear about checking out... This page in the manual talks about checking out from a remote source to the local repository..

https://confluence.atlassian.com/display/BITBUCKET/Checkout+a+branch+into+a+local+repository

Is this what you mean?

My first reaction was to switch to the develop branch and hit the checkout button on the toolbar. It requested that I select the branch that I wish to change my working tree to... Is this what you mean?

Many thanks for your patience with somebody who is learning.

You should also read chapters 1-3 of the Git Book.

In SourceTree, you can right-click on the branch name in the left pane, and select "Checkout...", or just double-click on it.

Sorted - thanks to both

Suggest an answer

Log in or Join to answer
Community showcase
Brian Ganninger
Published Jan 23, 2018 in Sourcetree

Tip from the team: workflow and keyboard shortcuts

Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...

274 views 0 3
Read article

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