So far, I only used the Visual Studio 2022 GUI.
On master, I committed some changes in file A. Then I realized, I should have created a new branch for those changes. So, I created a new branch feature-x and reverted the changes on master. I kept the changes on feature-x. On master and feature-x, I committed more changes. Today, I wanted to merge feature-x into master. There are certain changes on feature-x in file A that were on master, but were reverted. The merge process does not see these as changes. So, although there is a change in file A on feature-x, the merge does not show file A and the changes as "Staged Changes" or as "Unmerged Changes". This even results in erroneous code, because in file B a variable from file A is used but this variable is now not declared.
How can I add the changes to the merge?
Here's an image for clarification:
I found a rather simple solution: I cherry-picked the commits starting with the commit, I reverted on master. In above image, there are no commit IDs, so below, there are the corresponding times.
git cherry-pick --no-edit <id of commit from 15:19:02> <id of commit from 8:11:43> <id of commit from 10:44:53> <id of commit from 11:48:44>
--no-edit
tells git to keep the commit message.
There were merge conflicts with 2 commits. I solved them and continued with git cherry-pick --continue
.