Q:

SourceTree: updating develop and master when both are way behind active branch

I find myself in the middle of a project that has tried to use the git-flow approach for maintaining code.

https://blog.sourcetreeapp.com/2012/08/01/smart-branching-with-sourcetree-and-git-flow/
http://nvie.com/posts/a-successful-git-branching-model/

Because the git-flow strategies were not closely followed at the start of the project, the develop branch is months behind the latest feature branch, and the master branch is even further behind the develop branch. The feature- branches were being used as the branches for code deployment.
The question now is: using SourceTree, what is the best way to update the develop and the master branches, so that they are essentially exactly the same as the latest feature branch that was used for deployment? I don't see anything in develop or master being useful, since they are out of date and there have been so many changes, so it seems like they both need to be completely over-written.

A:

Since you don't need the changes from master or develop, the easiest solution would be to do a hard reset on those branches.

Switch to master by double-clicking it in the left pane.
Find the latest commit that has been deployed to production in the Log/History view.
Right-click that commit and click Reset current branch to this commit.
In the confirmation dialog, switch the Using mode dropdown to Hard - discard all working copy changes, then click OK.

And repeat the process for develop.

The alternative would be to delete the branches and re-create them.

Right click the master branch in the left pane.
Click Delete master.
At the confirmation dialog, if the branch has unmerged changes, check the Force delete box, then click OK.

Repeat the process for develop.
Then, take whatever feature-* branch was being used for production deployments, and rename it to master:

Right click on the relevant feature-* branch.
Click Rename feature-*....
Enter master and click OK.

If you have another feature-* branch that was being used for development, do the same to rename it to develop.
The main difference here is that you will no longer have the feature-* branches, which may or may not be what you need.
Effect on History
Suppose your history looked something like this:
... A--B [master]
   /
  *--*--*--C--D [develop]
         \
          *--* ... *--*--* [feature-1] (should be develop)
                  \
                   *--*--* [feature-2] (should be master)

After following the above instructions, your history will look like this:
... A--B
   /
  *--*--*--C--D
         \
          *--* ... *--*--* [develop, feature-1]
                  \
                   *--*--* [master, feature-2]

(Where feature-1 and feature-2 may not exist anymore depending on which solution you chose.)
When you move or delete a branch, the commits aren't deleted right away. So commits A, B, C, and D still exist, you just don't have an easy way to get to them. After a while these commits will be garbage-collected by Git, so be sure to add a branch or tag there if you want to keep them.

