4

I have a TortoiseGit repository locally, which is also pushed to a remote. There are 2 branches - master (the production version), and CodeFirst (a development branch).

Today I fixed a minor bug in the CodeFirst branch. I wanted to merge that change (just a single change to a single file) into master. I switched the local repo to master, chose merge, and selected the single commit. Once I pressed OK, master now seems to contain all the changes in the CodeFirst branch, not just the one I wanted.

How do I

a) Revert out the mistaken merge and commit

b) Reapply just that single change from CodeFirst to master

    [This revision is tagged CodeFirst and master in the TortoiseGit log. It is the commit I wanted to merge]
    Revision: 7d4c3d30aec8fb8e531331866c091dee8fa94f25
    Author: Nikki Locke <[email protected]>
    Date: 07/04/2015 18:03:37
    Message:
    Allow changing both accounts on new transfers.
    ----
    Modified: bin/banking/transfer.html

    [This revision is tagged origin/CodeFirst and master in the TortoiseGit log. I did not want to merge it to master!]
    Revision: ce94383e46285fb4f2af4dc21f850952ca65f250
    Author: Nikki Locke <[email protected]>
    Date: 02/04/2015 19:54:23
    Message:
    Fixed syntax errors in CASE statements
    ----
    Modified: Reports.cs

    [Many more revisions made in the CodeFirst branch omitted]

    [This revision is tagged origin/master in the TortoiseGit log]
    Revision: 68e1dff312b5927df01a9ab7e483f9163324b864
    Author: Nikki Locke <[email protected]>
    Date: 31/03/2015 19:04:01
    Message:
    Make Qty input box smaller.

    Put some css into invoice print to make it align correctly.
    ----
    Modified: bin/customer/print.html
    Modified: bin/default.js

1 Answer 1

6

To "revert" the merge open the log dialog and reset your branch/current HEAD to the commit before the merge (you want to keep).

Actually you don't want to merge another branch, but to cherry pick a commit. In the log click on the commit you want to pick and select "cherry-pick".

1
  • 1
    My HEAD is always detached when I do this. How do I recover from this? Nov 16, 2017 at 14:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .