Check Current Branch

 

Branches in Git
Git branches are part of your everyday development process. So git branches are effectively a pointer to a snapshot of your change.

When you want to add a new feature or fix a bug, regardless of its size, we create a new branch to encompass our modification. In summary, when I refer to new branches, I mean that branches are essentially an isolation of your modifications.

And once you're done with that, you will merge those changes to your release branch or master branch.

 

 

 

Method 1: Create a New Branch from main branch

See New Branch now

So at first, when you make a branch it gets cloned out of. It therefore essentially takes all the modifications. What that root branch possesses. Thus, every modification went into the develop branch. Which master branch possesses it?

 

 

Switch to develop branch

 

 

Check our Git Pointer

So basically both branches are in sync i.e. HEAD of both branch are same

 

lets do some change in develop branch

Commit my changes in develop branch

 

check log now

This show my HEAD pointer is moved from master to develop branch

 

Currently, if we generate a branch from this point in development, it will contain all of the modifications, all of the files, and all of the information what is in the development branch It will not contain any modifications from the master branch.

 

 

 

Method 2: Create and Switch to a New Branch from Develop branch

 

Only Switch between existing branches without Create a New Branch

 

 

Mark as Default branch

The default branch is the primary branch in your repository. When you clone a repository, this is usually the branch that is automatically checked out. It's often named main or master

  • In pull requests, the default branch is often suggested as the target branch for merging changes.
  • Administrators can typically configure which branch is the default branch for a repository.

 

 

 

Mark as Compare branch

The compare branch is a branch used as a baseline for comparing other branches. 

When you are viewing branches in a DevOps platform, you'll often see indicators of how many commits a branch is ahead of or behind the "compare branch." . It's often named default_dev branch, used for auto deployment in ci / cd

In Azure DevOps, you can explicitly set a "compare branch." The platform will then show the ahead/behind commit counts for all other branches relative to this compare branch. This setting is often user-specific

When creating a new pull request, some systems might default the target branch to the "compare branch" that the user has set.

DevOps show how may commit behind and ahead of compare branch

  •  

Related Question