![]() Set new local branches as tracking branches As a result, the tracking branch is known as "origin/prod". Assuming you pulled a branch named the "prod" branch from the "origin" remote. In some cases, you may want to connect your local branches to remote branches that you have just pulled or cloned from the main repository. Method 4 – Set upstream branch for an existing remote branch Please see How to install Git on macOS, How to Overlay two files with UnionFs in a Linux System, and How to Migrate Azure Web Apps. To do this, create a new bash alias with the "alias" command and give it a name, run: $alias gp='git push -u origin HEAD'Ĭreate a new branch and use our alias to easily push our code and create the upstream branch with the command below: $git checkout -b Setting up Upstream Branch Using Alias If you don’t want to change your existing git commands, you can use a bash alias. git pushdĪs you can the upstream branch has been set to "HEAD -> upstreamb" Method 3 – Set up Upstream Branch using a bash alias To setup upstream branch using alias, run: $git config -global alias.pushd "push -u origin HEAD"Īfter adding and committing files to your repository, utilize the command below with your defined alias to set the upstream branch. Note, pushing to HEAD is actually the same as pushing to a remote branch with the same name as your current branch. You can configure the upstream branch by creating an alias for the “git push” command. Method 2 – Set upstream branch using an alias Now you have successfully set the upstream branch for your newly created branch and git is tracking it. Now we can setup the upstream branch using the “git push” command for the new branch "upstreamb". Inspecting branches Setting Up and Tracking for ‘upstreamb’Īs you can clearly see, the branch upstreamb has no tracking branches compared to master and no upstream branches as well. Running the git branch command with the -vv flag allows you to inspect tracking branches. After creating the branch, run the below command to switch to it: $git switch Let’s create a branch called upstreamb with the command git branch or git checkout -b. Now to set upstream branches, run any of the command below: $git push -u OR $git push -set-upstream Setting up Upstream branches I have created my remote repo already as shown in the screenshot below: GitHub Remote Repository Review this post to learn how to create your first remote repository on GitHub. Now, add, commit and push the file to your remote GitHub repository.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |