Branching and merging in GitHub

less than 1 minute read

Branching and merging sometimes very difficult in github. For you wrong command it may destroy your repository. In this article, Branching and merging in github is discussed here step by step

Branching and merging in GitHub

  • To create a branch
    $ git checkout -b branch01
    Switched to a new branch 'branch01'
    or 
    $git branch branch01
    
  • To switch to a branch
    ```github $git checkout

Example $git checkout branch03


* **Push files to the a branch**  
First switch to the specific branch. Then add or modify files. To add files for the commit run the following command.
```github
$ git add .
$ git push origin <branch name>

Example:
$ git push origin branch01
  • Merge branch01 with master branch
    $ git checkout master
    Switched to branch 'master'
    Your branch is up-to-date with 'origin/master'.
    
$ git merge branch01
$ git commit -m "merge branch01"
$ git push

References