Create and Visualize Branch

1 minute read
0

Theory:

Branching is used in version control and software management to maintain stability while isolated changes are made to code. Branching facilitates the development to fix bugs, the addition of new capabilities, and the integration of new versions after they have been tested in isolation.

 

Procedure:

Step 1🡪Check the branch upon which you are working by using the command:

$ git branch

(The default branch is always the main branch.)


Step 2🡪Create a new local branch with:

$ git branch branch_name

(branch1 is the local branch created)

Step 3🡪 Use the git checkout command to navigate between the branches created by git.

$ git checkout sample1

 

Step 4🡪Add files to the new branch and commit it.

$ touch file name (Adding new file)

$ git add file name (To move a file from working to staging area)

$git status

$ vi filename(To make changes to the file)

$ git commit -m “message”



Step 5🡪Now, switch to the master branch and check if the file created in the above step is present or not.


 





To Top