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

Pushing Local BranchesPushing 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.

In our case, it may seem like an overhead; however, in practice, when you have other collaborators, this will allow them to review and test your code and provide feedback.

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.

In Git, upstream refers to the remote repository and branch that your local branch is tracking. When you set an upstream branch, your local branch knows which remote branch to push changes to and pull changes from. For example, setting the upstream branch with git push -u origin feature/payment tells Git that the local feature/payment branch should track the feature/payment branch on the origin remote.

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?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 3. Розділ 3
course content

Зміст курсу

GitHub Fundamentals

Pushing Local BranchesPushing 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.

In our case, it may seem like an overhead; however, in practice, when you have other collaborators, this will allow them to review and test your code and provide feedback.

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.

In Git, upstream refers to the remote repository and branch that your local branch is tracking. When you set an upstream branch, your local branch knows which remote branch to push changes to and pull changes from. For example, setting the upstream branch with git push -u origin feature/payment tells Git that the local feature/payment branch should track the feature/payment branch on the origin remote.

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?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 3. Розділ 3
some-alt