Search code examples
tortoisegit

What is the right way to try to make a revision to an existing commit of a merged feature branch?


I am still learning the features of using TortoiseGit and the concept of version control.

I have read the this article and it is not clear to me if I need to follow that procedure. It describes patching.

So, I have this feature branch that has now been merged into the master as indicated. I want to have a go at making a revision to the application with respects to one of the commits (highlighted). So I would like to try out an idea to do things differently and implement it if I am happy.

Log

What is the correct way to do this? I am a sole developer and am not in collaboration with others for my project.

Thank you for your advice.


Solution

  • There will always be times when you realize that a commit is not perfect or introduced an error.

    You have several options:

    1) Fix the issue and commit the fix on master (or in a bugfix/feature branch). You should do this, especially, if the "faulty" commit is some longer time ago.

    2) Option 1 might have the disadvantage that you don't know that this fix belogs to a recent feature branch. Here, you could switch to the feature branch again (if you already deleted the branch, re-create it on the latest commit before the merge), commit the fix there and merge the feature branch again to master. This way you can see in the log that this fix also belongs to the feature branch.

    3) The third option would be to rewrite your history - the is especially discouraged if you develop with other users and the "faulty" commit is already pushed or older. For rewriting history, go to the log dialog and open the context menu on the commit just before the faulty commit and select "Rebase ... onto this". Then the rebase dialog opens, check "Preserve merges" and "Force" there - then all commits starting with the "faulty" one should be displayed. Now, click on the "faulty" commit and mark it as "Edit" and then start the rebase. - Now your working tree is put back into that old state. Do your changes on the working tree, check "Edit/Split commit" and click on "Amend" on the rebase dialog. - After that all other remaining commits are re-applied and the fix is included in your history.

    PS: The article about patches and pull requests is about sharing changes with other developers.