How to create a branch in GitHub?
Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
Hello listeners, today, we are going to talk about how to make a branch in GitHub? Before, starting this article. Must you will read this article till the end. Let’s start to create a branch in GitHub. After knowing how to create a repository in GitHub?
What is the need for a branch in GitHub?
Suppose, you have your own repository from the name of GitHub training then you want to add any features in the code. You aren’t sure that you will do continue this feature or not, something has doubt in your mind. So, you’re adding some features like payment option, send money, or receive money. These three features, if you want to add but you aren’t sure about it. You will not commit these features in the master branch.
Creating branch in GitHub
If you will do commit in the master branch then your all latest file will make. Now, for these things, you will not sure then you will make a new branch on the name of the uncertain feature. So, you will do propose changes by selecting the option. You will look after doing so, all changes have come in written below the open a pull request like “the change you have made in written to a new branch name”.
How to create pull requests in GitHub?
If you will do create a pull request. Now, there will be your master branch and you will click on that latest file (requirement.txt) so, you will see that the payment option will not be added there. Again, you will return to code and you will do switch from master to uncertain feature. When you would do click on that latest file then all three features of your will be present in the uncertain feature. There will be branch form like one is the master branch and another is uncertain feature those you had made previously. Suppose, you have to do merge both of them, after some time you will have become sure that you have to do add all three features into the branch.
Git merge two branches
So, you go into code after that you will go into the pull request option. Then, you will click on the payment added option. There will come your pull requests, one of your requests will be there. Now, you will do merge pull requests with the option of this branch has no conflicts with the base branch. If you will do confirm then your two branches will be merged there. When you fetch to code, opening your master branch so, what will happen? When you will move into the file (requirement.txt), all of your three features will be added to your master branch due to merge. If you have to look at commits of code then you go to commits so, you will get every version uploaded there. Suppose, you have to see the previous version in which payment was not added so, you will get there, and if you have to see the payment added option which was in uncertain feature. So, you can go with the payment option which was in the uncertain branch. This is your version control system where how much excellently all of your versions will have kept. From anywhere, any code, even you can see a first commit which features you had added in starting. This is your version control and you have seen about the master branch.