I assume that you do not want to do any reinstallation and reset, this is a merge method.
Suppose you have two branches master and feature . So, you decided to combine the function in master :
$ git merge feature
You now have all of your feature changes on the host computer. I assume the most difficult scenario - commits are made after merging on both branches. But suddenly you see that nothing is working feature , everything is broken and decided to return it. Your story (you can see it with git log --graph feature master ):
* commit 838f29fda2333bdbfc0d1be44d2387e6119dc4e8 | | f3 | | * commit 58d1e3f0e032cc77d4ab2bbf0bdfe6407b96b7e6 | | | | m3 | | | * commit afb600fe382befe095f9b8a6e9eef98be25c929b | |\ Merge: 5cddc52 8660a59 | |/ |/| | | Merge branch 'feature' | | * | commit 8660a59eeb13f9b3447846ba6977140f7c86c7a4 | | | | f2 | | * | commit 6f76e2288d69808b97981340198fd8044ab47630 | | | | f1 | | | * commit 5cddc528de424a01d1d18552ddea93435618e2f7 | | | | m2 | | | * commit fa6ebb76f9f0308f7dcd1148503534668fa15358 |/ | | m1 | * commit 4e3aa05d6f46eb14bbbc253a42325e9a53a3393e
Note the f3 and m3 commits that were executed after the merge. So, you need to carefully remove only the changes from feature that appeared in master .
To do this, you can return the merge commit to master while maintaining the main base ( -m1 parameter). To do this, I create a new branch based on the merge point and return to it:
$ git checkout -b feature-revert afb600fe $ git revert -m1 HEAD
Now we have the restored changes on the feature-revert branch. Now itโs easy to just put it in a master by merging:
$ git checkout master $ git merge feature-revert
So, at the moment, master has nothing of feature . However, if you later want to re-merge the function, all returned changes will be lost in master, because they were merged and returned.
To solve the problem, you must return the reverse (he-he) and merge it back into feature :
$ git checkout feature-revert $ git revert HEAD $ git checkout feature $ git merge feature-revert
I suppose we no longer need a branch, since we have already merged it, but you can save it if you want:
$ git branch -d feature-revert
You should know that merging it returns all changes from master to feature , which is usually a normal workflow.
Now, after the corrections made to feature , you can merge it into master again as usual at any time.