Create New branch from master in GIT

1. Here am using master as the production branch.

2. Whenever i want to start new task it is the best way to start new branch instead work from production branch.

3. Use following command to create new branch

Syntax: git checkout -b <branchname>

Example: git checkout -b first_branch

4. Once you run the above command new branch will create & you switch to that branch, Mean

you created the copy of master branch with the name of first_branch .

5. In this branch you play whatever you want instead of doing directly in master branch.

6. Now go and check followint path .git/logs/refs/ here u will get one file called first_branch.

This is nothing but its ur new branch.Similarly whenever you create a new branch than the file

will create with each branch name in this section.

7. Now your in first_branch (use git branch command on terminal (or) check .git/HEAD )

8. Whenever you switch the branch those logs detail will saved in .git/logs/HEAD

 

Switch branch from one to another:
1. Usually whenever you want to switch the branch we have to use following command

git checkout <BRANCH NAME>

In Nature We Trust !! Save Agriculture !!!

 

Leave a Reply