How can we do branching from the command line?

Hello techno-friendly users, welcome to the featuring era of programming. Today, we shall raise our points on the topic of branching and how directly you can establish your branch through the git command line without opening the GitHub platform. If you will also unaware to take git branching so, you have difficulties in relation to command branching then you can receive every kind of solution related to creating, merging, and adding branches. This is the place where you could get all steps regarding branch creations.

Creating branch from the command line

Suppose, you have to make a branch so, letā€™s have a look that what is branch happening? If you have software and you are working in google and that Google is working in a master branch, all files are running there. Suppose, you want to add a feature in the file but you are not so sure to talking that your boss will give you permission or not. If you do in the main file that will be affected on your main server, the file has become loose then your server will be shut down. So, here comes the talk of the branch, you will make a copy, the branch means making copies of the same file. Then first, you will write git status so, it will show on branch master, nothing to commit. When you will put $ git branch then it will show you in the master branch, if you have to make a branch so, you will put $ git branch update code then update code is branch name happen. So, again, you will run the $ git branch, there will be branches as master and update code that you have been made. If you have to do the switch in the update code so, you will have to put like $ git checkout update code then it will show you switched to branch ā€˜update codeā€™ option. If you will move in the vs code file, you will do enhances in one then there will not be affected another file. Suppose, you have a file in the name contact.html, you have to write anything in that. You have been made a file in the name comment.html, you have paste similar code of your file and changed something code in that. If you will run git status then it will show you unstaged, when you will do commit through $ git commit ā€“a ā€“m ā€œthis update code files updatedā€. You will do update put anything message so, again, you will run git status then it will show you untracked files. Then you will first add that by putting $ git add ā€“A when you will run git status, it will show you on branch update code nothing to commit, working tree clean. When you will do switch to the master branch then you will see what will happen with comment.html so, you will have to see two branches that you had made by putting $ git branch.

Merging two branch command

You had made a file in the name comment.html then it will happen in the update code branch. So, again, you will switch by putting $ git checkout master then they will have switched to branch ā€˜masterā€™. When you will move to the vs code so, the comment.html file will not be there and also not visible in the file explorer because you had not that file in the master branch and you are updating that file in the update code. Again, you will do a checkout to update the code so, that the comment.html file will retrieve again in the vs code. This is the real meaning of branch, you can do switch, comment set up, add features also, and anything you want to do. Differently, you can make replicas of the project doing adding features in that, and after, you can merge them. Now, look at how can you do merge, what is merge means? Suppose, you have a project in the name comment.html in vs code, you have made that. You had made features in that boss has liked most, if they say that you have to give merge that with the master branch so, git has to give it directly. How does it do? So, what will be the command? First, you will see the git log by putting the $ git log then you will see files that will have been committed to those files you have done. By pressing Q, you have to give quit, first, you will have to move master. In master, you have to do merge update code then you will move by putting $ git checkout master so, it will have to give switch.

Now, one command is happen like $ git merge update code then you will have to go in the vs code that file has merged there. When you will have to give a close file from vs code then it will give to see you all files and features that have been added. That files were in an update code, you will see they have been shifted to master, whenever you will put git status then it will see on branch master, working tree clean. When you open vs code by putting $ code. Then you will see comment file will have arrived in the master branch. So, this real meaning happens of merge, it is a very good feature. Suppose, you are making a code differently or doing the work of some other person and after that, you have to do merge all of the codes then only you will put git merge along with branch name and from which branch. Itā€™s happened only, git shows us all work from professionally or the good way how ideally you are making and doing file. Suppose, you have to make a file of a node in that all Html files would work as backhand, you have to do server-side logics and make something in backhand. So, for giving him the layout, you will make a file of nodes. First, separately, you will have to make a branch then you will write $ git branch, and again, you will put $ git branch node integration, your branch will make. You will again put git branch then the branching file will show now, you have to make a file, and the direct switch also. It means that you make a branch, you want to do a switch. So, one command that is happening is $ git ā€“b nodeintegration.

Adding JavaScript branch

If you will put $ git ā€“b nodeintegration then it will show checkout changes. When you will do $ git checkout node integration then it will be switched to branch node integration. You will make a file in the name $ touch node.js so, you will see a file has been made in a vs code. Suppose, you have written anything in that like

console.log (ā€œthis is the server-side languageā€)  

console.log (ā€œthis is git hub trainingā€)

You have done a server-side in the node integration branch. Now, what can you do? Normally, you can check that. Suppose, you do $ git checkout master then your file node configuration will vanish from the vs code. You have made a file then first, you will add by putting $ git add ā€“A so, it will come in the staging area. Next, you will do it by putting $ git commit ā€“m ā€œthis is server-side js fileā€ then the file will be added so, you have committed all files. Suppose, you have to give branch change by adding $ git checkout master when you do switch from the master then the node.js file will have vanished because your file doesnā€™t exist in the master branch, it will exist in the node integration. Again, you will put as $ git checkout nodeintegration so, the file will be retrieved again in the vs code. It is the meaning of branch, and merge. You have looked at it.

Related video: