Vids
Vids

Reputation: 17

Visual Studio 2017 Unstaged changes vanishes after Merging from Master Branch to a release branch

I need to Merge selected changes from the 'Master' branch to a 'EnvT' branch.

During the Merge(Master to EnvT) lets say about 15 changes have been made to the 'Master' branch, all of the 15 changes is Staged and available within the 'Staged Changes', but out of those 15 changes I want to merge only 2 changes. So I Right Click on the 13 changes and 'Unstage' the changes. After resolving the merge conflicts I merge the 2 changes from the Master branch to the 'EnvT' branch. I commit the changes and push the changes to the 'EnvT' origin. All is well till now.

The problem is, the next time I do a merge from the 'Master' branch to the 'EnvT' branch the 13 changes that I 'Unstaged' in the previous merge operation does not appear under the 'Staged changes'. No matter what I do those changes does not come back in the next merge from Master to EnvT.

It would be awesome if someone can throw some light on what's going on. Any help would be highly appreciated.

Upvotes: 0

Views: 189

Answers (1)

Vids
Vids

Reputation: 17

I could not find a Visual Studio solution. This solution is based on Git Bash.

$ git diff --name-status EnvT..master| wc (get the total count of difference between EnvT branch and the master branch)

$ git checkout EnvT ( This is target branch, which will receive update from the 'master' branch)

$ git checkout master "C:/filefullpath/SQL/file1.sql" (Provide the full path of the file) Updated 1 path from 18b47878

$ git status

On branch EnvT Changes to be committed: (use "git restore --staged ..." to unstage) modified: /SQL/file1.sql

$ git commit -m 'Updated specific file into local branch from the master branch' $ git diff --name-status EnvT..master| wc (lastly get the number of changes , there should fewer differences).

After committing the changes I reopened the branch on Visual Studio 2017 and tried to Merge from Master to EnvT, I only saw the changes which have not been merged. The file merge that was done using Git Bash does not appear in the changeset during the Visual Studio Merge. Mission accomplished!

These articles were very helpful:

https://jasonrudolph.com/blog/2009/02/25/git-tip-how-to-merge-specific-files-from-another-branch/

How to merge specific files from Git branches.

Upvotes: 0

Related Questions