Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

Azure DevOps Services - Branches in Azure DevOps Repo Part - 4 #Branches #Createbranch #UsingserverRepository #Usinglocalrepository #AzureDevOpsRepo #AzureDevOpsServices

 


Branches in Azure DevOps Repos:

What are Branches?

When you are doing some changes in files and commit those changes then one commit id,

user info, Details of changes are generated.



Here, first arrow showing as master branch and below one is showing another branch like

develop branch. The connection between develop to master branch which is called

merging. 

 - Branch is a moveable pointer from a commit.

-     -  It has information about all previous commits.

When you created a new repository then one default branch is created like “Master”.

 

Why do we need branches?

As we know master branch is our main and always production ready branch. We need to

avoid making some changes directly on master branch.

The main purpose of branches is to avoid braking changes.


For E.g., suppose we have made some changes in our code and we commit those changes

in directly on master branch and if those changes are not working properly then it will push

to our higher environment and break the code. So here we need one more branch where

we first commit our changes and test in our dev environment. If everything is working

properly then we will merge this develop branch with master and avoid the code break.

 

Git Branches:

-          We can create branch from any commit.
-          It means new branch can be created from other branch.
-          Git tracks current working branch using HEAD. Head is available in. git hidden file.
-          When we switch our branch then the HEAD points to the new branch.

 

Way to create a new branch:

-          ­1. Using server repository

-          2. Using local repository

 

Right now, in our project only one master branch is available which is default like:



You also test the same from branches menu at left side under repo like:




You can also test current list of branches in our repository using command prompt and git

command using “git branch” like:



You can also check the same through VS-2019 like:




In VS why its showing 2 folder because here remote/origin showing all branches from

server and above one showing local branches. Current branch is showing in bold format. 


Create new branch using Server Repository:

To create a new branch on server repository just refer the below diagram:




Just go to branch option at left side -> click on New branch button -> In new window put

 your branch name under main branch i.e., master and click create button.



Here now branch is created.


How to switch branch in multiple way like:

Using Command - How we can check:



Using Tortoise git:

Just right click -> Tortoise git -> Switch/Checkout > new window will open -> just select new

 branch name from dropdown if you already checkout the branch like:




Using VS:



 Here master is our current branch because its showing bold. For switching the branch just

 right click on develop branch and select checkout like




Now here develop is our current branch showing in bold.


How to create new branch using local repository:

Here we learn how to create a branch in local repository and sync those branches with server.

There are multiple ways to create a branch in local repository like:

1)      Using git command: To create a branch using git command follow the below step:

Just open your local repository folder like: 


Here first we check how many branches currently exist in local repository using “git branch” command.

Then using “git branch” command with branch name we create a new branch i.e., “git branch 

developlocal” – here #developlocal is branch name. Now again we need to check the total branches 

using “git branch” command. You want to switch the branch then you can switch it using checkout 

command like “git checkout developlocal”.




Using Tortoise git:   just right click on your local repository:


Here just enter the branch name – click ok.

At server end there are only two branches are available like:



Now we need to sync that local branch to server repository. How we can do that using git push

 command like:


Here upstream means branch related to server. Now we sync the local branch with server,



 

Using VS: Open the VS and create the branch like:


Here click on New Branch:




Enter the branch name and click on create button. Then check using manage branch like:




Now push the changes to server like:




At server end repository now sync like:



Hope you understand the concept of Azure DevOps Branches and all.

Thanks. 👍🙏










Post a Comment

0 Comments