Skip to main content

How to create a new branch and works on that branch

In this git tutorial we will see how we can create branches in github, checkout the code in local and make changes also how to commit changes and push it to github

* How to create branch in git hub

* How to checkout specific branch in local system

* How to switch to different branches in local git using command prompt

* How to add changed files to git local repository

* How to commit code changes to local repository 

* How to push code changes from specific branch

* How to set upstream while pushing changes to github

Let's get started...

1. How to checkout code from specific branch

    git clone -b BranchName giturl

    if you want to create a new branch in your local use the below command

    -> How to create branch in local git

                git branch BranchName

    -> How to switch to other local branch
            
               git checkout BranchName

2. How to add new files in local git after checkout

    git add .

3. How to commit changes

    git commit -m "your_message"

4. How to push any branch to github

    git push --set-upstream origin BranchYouAreIn


Check out the below video for complete understanding



Comments