Friday 8 June 2018

Version Control in VS for Mac - How to select certain changes made from a branch into another via the Merge process...

Version Control in VS for Mac
Selectively choose the changes you want to be in the new branch when trying to merge from other branch via stage and unstage method. 


Scenario: 

Your branches:
One Master branch.
One Staging branch. 

Assumption:
You treat master branch as your daily development branch. 
Both branches have a same file called 'Detail.xaml'. 
You plan to merge some changes done master branch into your staging branch. 

Ok... let's start: 


1) 
Add a new line in detail.xaml. e.g.: 
<Label Text="This line is for master only"/>
The commit it,. and push it to master branch. 

2)
Add another line in detail.xaml (underneath the label) . e.g: 
<Label Text="This line is for master only"/>
<Label Text="This line is for staging only"/> <----- div="" line.="" nbsp="" new="">Then, commit it, and push it to master branch. 


3)
Add another line in detail.xaml .e.g:
<Label Text="This line is for master only"/>
<Label Text="This line is for staging only"/>
<Label Text="This new line is for master only"/> <----- div="" line.="" nbsp="" new="">
Then, commit it, and push it to master branch. 

With the above changes done on master branch, you should have something looks like this in your git view: 



Merge my changes into Staging

1. I switch my branch to staging first. Then click on the merge button. This will allow me choose 'Merge from Log' or 'Merge Fetched'.  (I am not clear what is the differences between these). 

I usually go for 'Merge from log',  so that I can choose the changes via log view. 
See the image below (note! I will untick the 'Commit merge immediately'):


2. Click OK,. then,.. check out the File Status on the left menu: 
Click on the File Status. 
Click on the file name. 
Right click the line in source code window. 
Choose 'Unstage selected line'. 


3. Once you have done the steps as above (After onstage a selected line),.. 
Your file will fall into 'Unstage file' section:
highlight the line you want DO NOT to be merged into staging.
Right click, then choose 'Discard selected line'. 


4. Two lines have been discarded from the source:




5. Move your file from 'Unstaged File' back to 'Staged File' by clicking on the check box next to the file name in 'Unstraged File' section. 

6. Then.. remember you need to COMMIT your file first. 
And finally PUSH your change to remote staging. 

Job done.  Double check the changes from the source code.  
And,  both the staging and master branches are in the same development line now: 

Done!
---




No comments:

Post a Comment

How to run unit test for your Xamarin Application in AppCenter?

How to run unit test for your Xamarin application in AppCenter?  When we talk about Building and Distributing your Xamarin app, you m...