Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Pushing Local Branches | More Advanced Workflows
GitHub Fundamentals
course content

Course Content

GitHub Fundamentals

GitHub Fundamentals

1. Introduction to GitHub
2. Basic Interaction with Remotes
3. More Advanced Workflows

bookPushing Local Branches

Creating a separate branch for a new feature is an extremely common practice when using Git. Suppose we want to implement a payment system in our project, so let's create a feature/payment branch and switch to it immediately:

Once on this branch, we will make some changes in the test.txt file as if we were adding some lines of code to implement a payment system. Let's simply append this line: "A few lines of code" to the file:

Next, we can make a direct commit:

We now have a commit on our feature/payment branch. Before merging this branch into the main branch, let's first push it to the remote repository.

The first time we push a new branch to the remote repository, we need to include some additional parameters in the git push command. Specifically, we need to use the -u flag to set up the branch to track the corresponding remote branch (known as upstream). We also need to specify that we are pushing to the origin repository and indicate that we are pushing the feature/payment branch.

What is the correct command to push a newly created branch `feature/login` to the remote repository and set it to track the remote branch?

What is the correct command to push a newly created branch feature/login to the remote repository and set it to track the remote branch?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 3. Chapter 3
We're sorry to hear that something went wrong. What happened?
some-alt