{"id":5053,"date":"2023-07-20T01:06:10","date_gmt":"2023-07-20T01:06:10","guid":{"rendered":"https:\/\/arzhost.com\/blogs\/?p=5053"},"modified":"2024-10-14T19:24:02","modified_gmt":"2024-10-14T14:24:02","slug":"git-upstream-set-upstream-branch","status":"publish","type":"post","link":"https:\/\/arzhost.com\/blogs\/git-upstream-set-upstream-branch\/","title":{"rendered":"What Is Git Upstream and How to Set Upstream Branch?"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/arzhost.com\/blogs\/git-upstream-set-upstream-branch\/#Introduction_to_Git_Upstream_and_Why_is_it_Important\" >Introduction to Git Upstream and Why is it Important<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/arzhost.com\/blogs\/git-upstream-set-upstream-branch\/#What_is_a_Git_Upstream_Branch\" >What is a Git Upstream Branch?&nbsp;<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/arzhost.com\/blogs\/git-upstream-set-upstream-branch\/#How_to_Set_Upstream_Branch_in_Git\" >How to Set Upstream Branch in Git?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/arzhost.com\/blogs\/git-upstream-set-upstream-branch\/#Remote_Work_Made_Easy_%E2%80%93_Sign_Up_now_Save_Big_Today\" >Remote Work Made Easy \u2013 Sign Up now &amp; Save Big Today!<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/arzhost.com\/blogs\/git-upstream-set-upstream-branch\/#Method_1_Setting_Upstream_Branch_Using_Git_Push\" >Method 1: Setting Upstream Branch Using Git Push<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/arzhost.com\/blogs\/git-upstream-set-upstream-branch\/#Method_2_Set_Upstream_Branch_Using_Alias\" >Method 2: Set Upstream Branch Using Alias<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/arzhost.com\/blogs\/git-upstream-set-upstream-branch\/#How_to_Modify_the_Git_Upstream_Branch\" >How to Modify the Git Upstream Branch?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/arzhost.com\/blogs\/git-upstream-set-upstream-branch\/#One_Payment_Lifetime_Hosting%E2%80%94Sign_Up_Now_and_Save_59\" >One Payment, Lifetime Hosting\u2014Sign Up Now and Save 59%!<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/arzhost.com\/blogs\/git-upstream-set-upstream-branch\/#How_to_Determine_Which_Git_Branches_Track_Each_Upstream_Branch\" >How to Determine Which Git Branches Track Each Upstream Branch?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/arzhost.com\/blogs\/git-upstream-set-upstream-branch\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Introduction_to_Git_Upstream_and_Why_is_it_Important\"><\/span>Introduction to Git Upstream and Why is it Important<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You need to understand What Is Git Upstream and How to Set Upstream Branch? and how to set it up before you can clone a Git repository or add new features using branches.<\/p>\n\n\n\n<p>This article from our <a href=\"https:\/\/arzhost.com\/blogs\/\"><strong>blog<\/strong><\/a> provides a general overview of <span style=\"color: #000000;\"><strong>What Git Upstream is and How to Set the Upstream Branch<\/strong><\/span>? as well as how to see which Git branches are tracking which upstream branches.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Installed and set up Git<\/li>\n\n\n\n<li>a locally built-up Git project or a cloned Git repository<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_is_a_Git_Upstream_Branch\"><\/span><strong>What is a Git Upstream Branch?&nbsp;<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Upstream is delivering your data back to where the river stream is coming from, using a river analogy to describe the flow of data. Sending anything upstream means returning it to the repository&#8217;s founding authors.<\/p>\n\n\n\n<p>You can decide where your current local branch will flow by using git set upstream. You are able to modify the remote branch&#8217;s default setting.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Set_Upstream_Branch_in_Git\"><\/span><strong>How to Set Upstream Branch in Git?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><u>What Is Git Upstream and How to Set Upstream Branch? In Git, there are two methods for creating an upstream branch:<\/u><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The quickest way to create a single upstream branch is to use git push.<\/li>\n\n\n\n<li>By means of a brief alias command. If you frequently alter the flow of your current branch, then this approach makes sense.<\/li>\n<\/ol>\n\n\n\n<div class=\"wp-block-uagb-call-to-action uagb-block-684ca900 wp-block-button uag-blocks-common-selector\" style=\"--z-index-desktop:479;;--z-index-tablet:undefined;;--z-index-mobile:undefined;\"><div class=\"uagb-cta__wrap\"><h2 class=\"uagb-cta__title\"><span class=\"ez-toc-section\" id=\"Remote_Work_Made_Easy_%E2%80%93_Sign_Up_now_Save_Big_Today\"><\/span><a href=\"https:\/\/arzhost.com\/rdps\/\" data-type=\"link\" data-id=\"https:\/\/arzhost.com\/rdps\/\">Remote Work Made Easy \u2013 Sign Up now &amp; Save Big Today!<\/a><span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"uagb-cta__desc\">Secure &amp; Fast Window VPS by <strong>ARZ Host<\/strong>\u2013 Start for Just $18\/month with Our Limited-Time Offer!<\/p><\/div><div class=\"uagb-cta__buttons\"><a href=\"https:\/\/arzhost.com\/rdps\/\" class=\"uagb-cta__button-link-wrapper wp-block-button__link\" target=\"_self\" rel=\"noopener noreferrer\">Read More<\/a><\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Method_1_Setting_Upstream_Branch_Using_Git_Push\"><\/span><strong>Method 1: Setting Upstream Branch Using Git Push <\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><u>The simplest method for creating upstream branches in Git is to use git push.<\/u><\/p>\n\n\n\n<p>1: Establish a new branch and name it. Ours is called a test. Use the checkout command&#8217;s -b option to switch to it:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>branch name> git checkout<\/code><\/li>\n<\/ul>\n\n\n\n<p><u>An indication of the switch branch appears:<\/u><\/p>\n\n\n\n<p><iframe title=\"YouTube video player\" src=\"https:\/\/www.youtube.com\/embed\/csHeaYWspic\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n\n\n\n<p>2: Create an upstream branch by using the longer \u2014set-upstream command or the git push command with the -u extension. Change branch name&gt; to the name of your branch.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>branch name> git push -u origin<\/code><\/li>\n<\/ul>\n\n\n\n<p><u>Alternatively:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>\u2014set-upstream origin git push branch name><\/code><\/li>\n<\/ul>\n\n\n\n<p><u>Your branch is verified as having been set up to track a remote branch:<\/u><\/p>\n\n\n\n<p>There is an established upstream branch for the test branch. Getting the error 403? Fix it with out guide <a href=\"https:\/\/arzhost.com\/blogs\/git-push-permission-denied-403\/\"><strong>Git Push Permission Denied 403<\/strong><\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Method_2_Set_Upstream_Branch_Using_Alias\"><\/span><strong>Method 2: Set Upstream Branch Using Alias<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Establish a quick alias command instead of repeating these steps each time you create a new branch. You can write a bash command or alter your current Git commands.<\/p>\n\n\n\n<p><u>1: Use the \u2014global command in git config to configure the global alias command:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>\u2014global alias. Alias name> in git configuration \"pushing -u origin HEAD\"<\/code><\/li>\n<\/ul>\n\n\n\n<p><u>What Is Git Upstream and How to Set Upstream Branch? Alternately, use alias to build a bash alias command:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Alias 'git push -u origin HEAD' = 'alias name'<\/code><\/li>\n<\/ul>\n\n\n\n<p><u>2: Type: to use your global alias.<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>git \u2014aliases<\/code><\/li>\n<\/ul>\n\n\n\n<p><u>Or by entering the name of your bash alias:<\/u><\/p>\n\n\n\n<p>The alias name<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Modify_the_Git_Upstream_Branch\"><\/span><strong>How to Modify the Git Upstream Branch?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><u>Run: to track an alternative upstream branch to the one you just created.<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>git branch -u \"name of remote branch\"<\/code><\/li>\n<\/ul>\n\n\n\n<p><u>For instance:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>origin\/global> git branch<\/code><\/li>\n<\/ul>\n\n\n\n<p>A confirmation message is printed out by the terminal:<\/p>\n\n\n\n<div class=\"wp-block-uagb-call-to-action uagb-block-62ca8e6f wp-block-button uag-blocks-common-selector\" style=\"--z-index-desktop:479;;--z-index-tablet:undefined;;--z-index-mobile:undefined;\"><div class=\"uagb-cta__wrap\"><h2 class=\"uagb-cta__title\"><span class=\"ez-toc-section\" id=\"One_Payment_Lifetime_Hosting%E2%80%94Sign_Up_Now_and_Save_59\"><\/span><a href=\"https:\/\/arzhost.com\/lifetime-web-hosting\/\" data-type=\"link\" data-id=\"https:\/\/arzhost.com\/lifetime-web-hosting\/\">One Payment, Lifetime Hosting\u2014Sign Up Now and Save 59%!<\/a><span class=\"ez-toc-section-end\"><\/span><\/h2><p class=\"uagb-cta__desc\">Hosting for Life at a One-Time Price\u2014Exclusive <strong>59% Discount<\/strong> Today!<\/p><\/div><div class=\"uagb-cta__buttons\"><a href=\"https:\/\/arzhost.com\/lifetime-web-hosting\/\" class=\"uagb-cta__button-link-wrapper wp-block-button__link\" target=\"_self\" rel=\"noopener noreferrer\">Read More<\/a><\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Determine_Which_Git_Branches_Track_Each_Upstream_Branch\"><\/span><strong>How to Determine Which Git Branches Track Each Upstream Branch?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><u>Use the -vv option of the git branch to display a list of all your branches and branch tracking:<\/u><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>branch -vv for git<\/code><\/li>\n<\/ul>\n\n\n\n<p>A tracking branch named [origin\/main] is present on the main branch. The tracking branch for the test branch is [origin\/global]. The global branch has no upstream branch and no tracking branches.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><strong>Conclusion<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>What Is Git Upstream and How to Set Upstream Branch? should now be familiar to you, along with their purpose and, most importantly, how to create one in <a href=\"https:\/\/git-scm.com\/\" target=\"_blank\" rel=\"noopener\"><strong>Git<\/strong><\/a>.<\/p>\n\n\n\n<p>Experiment freely and become accustomed to upstream. A git branch can be quickly deleted <strong>both locally and remotely<\/strong>, as well as eliminated from a repository. For more Articles like this and the latest news, Subscribe to our <a href=\"https:\/\/arzhost.com\/blogs\/\"><strong>blog<\/strong><\/a>.<\/p>\n\n\n\n<p><strong>Latest Posts:<\/strong><\/p>\n\n\n<ul class=\"wp-block-latest-posts__list wp-block-latest-posts\"><li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/arzhost.com\/blogs\/how-to-fix-403-forbidden-error-wordpress\/\">How To Fix 403 Forbidden Error WordPress<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/arzhost.com\/blogs\/how-to-get-the-most-out-of-claude-ai\/\">How To Get The Most Out Of Claude Ai<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/arzhost.com\/blogs\/bad-gateway-error-502-the-ultimate-guide-to-quick-fixes\/\">Bad Gateway Error (502): The Ultimate Guide to Quick Fixes<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/arzhost.com\/blogs\/a-deep-dive-into-todays-best-linux-distros\/\">A Deep Dive Into Today\u2019s Best Linux Distros<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/arzhost.com\/blogs\/domain-investor-terms-powerful-strategy\/\">Domain Investor Terms: Expert Insight on Powerful Strategy<\/a><\/li>\n<\/ul>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction to Git Upstream and Why is it Important You need to understand What Is Git Upstream and How to Set Upstream Branch? and how to set it up before you can clone a Git repository or add new features using branches. This article from our blog provides a general overview of What Git Upstream [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6032,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"table_tags":[],"class_list":["post-5053","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorial"],"_links":{"self":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts\/5053","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/comments?post=5053"}],"version-history":[{"count":4,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts\/5053\/revisions"}],"predecessor-version":[{"id":6033,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/posts\/5053\/revisions\/6033"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/media\/6032"}],"wp:attachment":[{"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/media?parent=5053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/categories?post=5053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/tags?post=5053"},{"taxonomy":"table_tags","embeddable":true,"href":"https:\/\/arzhost.com\/blogs\/wp-json\/wp\/v2\/table_tags?post=5053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}