How to create and merge branches on github
So, for creating a new branch we have to execute checkout command with new branch name. You can provide any branch name and a new branch with that name will be created in your repository.
git checkout -b Branch Name
git checkout -b firstBranch
So, after checkout the new branch you have switched to new branch and now we need to add files that we need to add to this branch. So we will use git add * for that purpose.
git add *
git add *
Previous command will add up all files to your commit list but it will not commit the changes unless you use commit command that is explained below:
git commit -m "change memory streem name"
git commit -m "change memory streem name"
Commit will commit or save your changes in local repository that are finalized to be pushed to repository.We have to always commit the changes before pushing. You can add any comment there to remember what was the commit all about.
After commit now we have to push the changes to origin , now after origin we have to specify the branch where we want to push our changes. So in the next command we have used firstbranch which was a new branch and the commited changes will be pushed to that branch.
git push -u origin firstBranch
git push -u origin firstBranch
Now, for merging the new branch and existing branch we have to do this
Merging firstBranch to Master Branch
git checkout master git pull origin firstBranch
So this is how can add new branch and push your changes to new branch and merge branches on github.