I need to locally rollback to a previous commit in sourcetree because code is missing from a deployment, but I do not want to lose all the work done that has been committed and pushed since that earlier commit.
I find sourcetree's terminology and options confusing and sometimes they don't work as I would expect them to.
How do I do rollback to get previous versions of files to make changes without losing the changes made recently? Thanks!
You can select any commit and then select any file within that commit, right click, open selected version.
That will open the version of the file at the time of the selected commit. You can copy and paste changes to the current version of the file.
Without knowing the specifics of your project that's the best approach I can suggest.
In other scenarios you can reset a branch to a particular commit or reset just 1 file to how it used to be in a particular commit or cherry pick another commit onto your current branch or Reverse Commit to undo all changes that were introduced in a particular commit.
The solution that you are probably looking for is called "rebasing". It's a method within git where you rewrite a portion of the git history.
However, this is a very bad approach if you've already pushed the commits you want to modify. The reason for this, is that rebasing essentially discards the old commits and creates new ones with new hashes. Any coworkers/team members that have pulled the unedited commits are going to start getting very strange error messages if they try to do any work in that branch, and will have to jump through a bunch of hoops to "repair" their local repositories.
The right solution is to just make a new commit that has the fix you need, and deploy that instead of whatever you are currently trying to deploy.
Badges are a great way to show off community activity, whether you’re a newbie or a Champion.Learn more
Supported Platforms macOS Windows To make using Sourcetree as simple yet powerful as possible we embed (bundle) dependencies such as Git, Git LFS, and Mercurial. We strive to keep these...
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!
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