Thursday, 21 January 2016

All you need to know about creating branch and sending git pull request with Visual Studio Team Services

We can benefit a lot from by simply adding pull request and code review in our process of application development. In my opinion code review should be must and not optional. It may take time to bring everyone on board but every single person can benefit from the change later.


1- Reduce number of bugs because we find bugs early
2- It helps to keep code consistent 
3- More people are across the same user story (business rules, code implementation)
4- Developers have better view and bigger picture of solution
5- Teaching and sharing knowledge on best practices 

Mapping working item and git commit:

It would be a good practice if we ask everyone to add #{work item id} in their commit. It will help to track commits in TFS.
It would be easier for testers/managers to see if any work has been done for the particular bug or task, also it will save time for trouble shooting in future.


If you add #taskID in your commit visual studio team services picks the commit and maps it with work item





resource:
https://visualstudio.uservoice.com/forums/330519-team-services/suggestions/4038344-associate-a-git-commit-with-a-work-item
http://www.codewrecks.com/blog/index.php/2013/01/31/associate-work-items-to-check-in-in-a-tf-service-git-enabled-repository/

Creating New branch:

For creating branch we need to follow the following steps

1-     Switch  to your master branch
2-     Make sure having the latest version on our local
3-     Create a new branch based on  your master branch

Using Team Explorer:

Open Team Explorer  view in visual studio

1-     Switch  to your master branch
open branches tab
2-     Make sure you have the latest version running
right click on your master branch and select checkout



3-     create a branch
right click on the local master branch ( the one you want to create a branch from ) and select New Local Branch from... 




Using visual studio Online:

Go to https://{yourdomain}.visualstudio.com
Select Project and then click on Code then select Explorer
https://{yourdomain}.visualstudio.com/DefaultCollection/_git/{yourproject}





Using git bash:

Open git bash, go to your repository directory

1-     switch  to your master branch
git checkout feature
2-     make sure you have the latest version by running
git pull origin <master branch name>
3-     create a branch
git checkout –b <branch name>



More read:
 https://www.atlassian.com/git/tutorials/using-branches/git-branch


Pull Request:

Using team Explorer:




Click on New Pull Request



Using visual studio Online:

Go to https://{yourdomain}.visualstudio.com
Select Project and then click on Code then select Pull Requests
https://{yourdomain}.visualstudio.com/DefaultCollection/_git/{project name}







Add Reviewers:



Approve review:

https://{yourdomain}.visualstudio.com/DefaultCollection/_git/{project name}








More resource:
https://channel9.msdn.com/Events/Visual-Studio/Connect-event-2015/207
http://blogs.msdn.com/b/visualstudioalm/archive/2014/06/10/git-pull-request-visual-studio-online.aspx