{"id":22838,"date":"2020-09-17T14:53:00","date_gmt":"2020-09-17T21:53:00","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=22838"},"modified":"2020-12-29T12:37:17","modified_gmt":"2020-12-29T20:37:17","slug":"git-no-upstream-branch","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/git-no-upstream-branch\/","title":{"rendered":"Git Fixes: The Current Branch Has No Upstream Branch"},"content":{"rendered":"\n<p>It might happen that you are working on your regular day-to-day coding. You create a new branch, make some commits and then after doing <code>git push<\/code> you get this error:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>fatal: The current branch &lt;branchname&gt; has no upstream branch.\nTo push the current branch and set the remote as upstream, use\n\n    git push --set-upstream origin &lt;branchname&gt;<\/pre><\/div>\n\n\n\n<p>This happens because of your newly created branch. Your Git is not configured to create that same branch on remote. So you are creating that branch only on your local. In order to fix this we need to add more options to our git push command.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Ways to go about solving this issue<\/strong><\/h2>\n\n\n\n<p>There are many ways to solve this issue. The first of them would be to just follow the instructions above.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>git push --set-upstream origin master<\/pre><\/div>\n\n\n\n<p>We caution you to <strong>not<\/strong> use this command, why? Because you don&#8217;t need to set up an upstream. If you set upstream this way you could have weird and unexpected consequences in your repository. Because of unexpected consequences this option has been <strong>deprecated<\/strong>.<\/p>\n\n\n\n<p>There are other ways and as exemplified above we will need to add more options to our <code>git push<\/code>. For example.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>git push -u origin master<\/pre><\/div>\n\n\n\n<p>This will automatically create the branch with the same name of your local on remote. The -u creates that branch on the remote repo. If you ever get an error while doing this command just add the <code>--all<\/code> flag at the end: <code>git push -u origin --all<\/code>.<\/p>\n\n\n\n<p><strong>Note<\/strong>: You might be tempted to omit <code>-u<\/code> and just do <code>git push origin &lt;branch-name&gt;<\/code>. If you don&#8217;t add this flag when you do <code>git pull<\/code> at some point it will not work as expected and Git will give you some additional errors. So do stick to adding the <code>-u<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Configuring Git so you can use <\/strong><strong>git push<\/strong><strong> alone<\/strong><\/h2>\n\n\n\n<p>If you still want to use <strong>git push alone<\/strong> without having this error, you&#8217;ll need to configure git. There\u2019s a way to always create a remote branch whenever you create a new local branch. We do this with the following command:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>git config --global push.default current<\/pre><\/div>\n\n\n\n<p>With this fix you are good to go to use <code>git push<\/code> without seeing this error again!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>Whenever we work on new branches, most of us have seen this error. We could either configure git to always push to remote as we create the branch or just make that decision ourselves by adding the <code>-u<\/code> flag to our <code>git push<\/code> command.<\/p>\n","protected":false},"excerpt":{"rendered":"It might happen that you are working on your regular day-to-day coding. You create a new branch, make some commits and then after doing git push you get this error: fatal: The current branch &lt;branchname&gt; has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin&hellip;","protected":false},"author":86,"featured_media":12811,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17286],"tags":[],"class_list":{"0":"post-22838","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-git"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Git","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Git Fixes: The Current Branch Has No Upstream Branch | Career Karma<\/title>\n<meta name=\"description\" content=\"The Current Branch Has No Upstream Branch. Have you seen this error in Git? We&#039;ll show you what it is and how to fix it. Learn Git with CareerKarma.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/git-no-upstream-branch\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Git Fixes: The Current Branch Has No Upstream Branch\" \/>\n<meta property=\"og:description\" content=\"The Current Branch Has No Upstream Branch. Have you seen this error in Git? We&#039;ll show you what it is and how to fix it. Learn Git with CareerKarma.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/git-no-upstream-branch\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-09-17T21:53:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-29T20:37:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/code-coding-computer-developer-574080.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"663\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Felipe Boh\u00f3rquez\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Felipe Boh\u00f3rquez\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-no-upstream-branch\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-no-upstream-branch\\\/\"},\"author\":{\"name\":\"Felipe Boh\u00f3rquez\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e2cbf72dcbfaf9e81a8b6a38c1bd4220\"},\"headline\":\"Git Fixes: The Current Branch Has No Upstream Branch\",\"datePublished\":\"2020-09-17T21:53:00+00:00\",\"dateModified\":\"2020-12-29T20:37:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-no-upstream-branch\\\/\"},\"wordCount\":366,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-no-upstream-branch\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/code-coding-computer-developer-574080.jpg\",\"articleSection\":[\"Git\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-no-upstream-branch\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-no-upstream-branch\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-no-upstream-branch\\\/\",\"name\":\"Git Fixes: The Current Branch Has No Upstream Branch | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-no-upstream-branch\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-no-upstream-branch\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/code-coding-computer-developer-574080.jpg\",\"datePublished\":\"2020-09-17T21:53:00+00:00\",\"dateModified\":\"2020-12-29T20:37:17+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e2cbf72dcbfaf9e81a8b6a38c1bd4220\"},\"description\":\"The Current Branch Has No Upstream Branch. Have you seen this error in Git? We'll show you what it is and how to fix it. Learn Git with CareerKarma.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-no-upstream-branch\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-no-upstream-branch\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-no-upstream-branch\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/code-coding-computer-developer-574080.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/code-coding-computer-developer-574080.jpg\",\"width\":1000,\"height\":663},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git-no-upstream-branch\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Git\",\"item\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/git\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Git Fixes: The Current Branch Has No Upstream Branch\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e2cbf72dcbfaf9e81a8b6a38c1bd4220\",\"name\":\"Felipe Boh\u00f3rquez\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/Screen-Shot-2020-08-17-at-11.10.42-AM-150x150.png\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/Screen-Shot-2020-08-17-at-11.10.42-AM-150x150.png\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/Screen-Shot-2020-08-17-at-11.10.42-AM-150x150.png\",\"caption\":\"Felipe Boh\u00f3rquez\"},\"description\":\"Felipe Boh\u00f3rquez is a Software Engineer and technical writer at Career Karma. He covers all things frontend and backend development.\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/author\\\/felipe-bohorquez\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Git Fixes: The Current Branch Has No Upstream Branch | Career Karma","description":"The Current Branch Has No Upstream Branch. Have you seen this error in Git? We'll show you what it is and how to fix it. Learn Git with CareerKarma.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/careerkarma.com\/blog\/git-no-upstream-branch\/","og_locale":"en_US","og_type":"article","og_title":"Git Fixes: The Current Branch Has No Upstream Branch","og_description":"The Current Branch Has No Upstream Branch. Have you seen this error in Git? We'll show you what it is and how to fix it. Learn Git with CareerKarma.","og_url":"https:\/\/careerkarma.com\/blog\/git-no-upstream-branch\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-09-17T21:53:00+00:00","article_modified_time":"2020-12-29T20:37:17+00:00","og_image":[{"width":1000,"height":663,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/code-coding-computer-developer-574080.jpg","type":"image\/jpeg"}],"author":"Felipe Boh\u00f3rquez","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"Felipe Boh\u00f3rquez","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/git-no-upstream-branch\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/git-no-upstream-branch\/"},"author":{"name":"Felipe Boh\u00f3rquez","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e2cbf72dcbfaf9e81a8b6a38c1bd4220"},"headline":"Git Fixes: The Current Branch Has No Upstream Branch","datePublished":"2020-09-17T21:53:00+00:00","dateModified":"2020-12-29T20:37:17+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/git-no-upstream-branch\/"},"wordCount":366,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/git-no-upstream-branch\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/code-coding-computer-developer-574080.jpg","articleSection":["Git"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/git-no-upstream-branch\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/git-no-upstream-branch\/","url":"https:\/\/careerkarma.com\/blog\/git-no-upstream-branch\/","name":"Git Fixes: The Current Branch Has No Upstream Branch | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/git-no-upstream-branch\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/git-no-upstream-branch\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/code-coding-computer-developer-574080.jpg","datePublished":"2020-09-17T21:53:00+00:00","dateModified":"2020-12-29T20:37:17+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e2cbf72dcbfaf9e81a8b6a38c1bd4220"},"description":"The Current Branch Has No Upstream Branch. Have you seen this error in Git? We'll show you what it is and how to fix it. Learn Git with CareerKarma.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/git-no-upstream-branch\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/git-no-upstream-branch\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/git-no-upstream-branch\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/code-coding-computer-developer-574080.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/code-coding-computer-developer-574080.jpg","width":1000,"height":663},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/git-no-upstream-branch\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Git","item":"https:\/\/careerkarma.com\/blog\/git\/"},{"@type":"ListItem","position":3,"name":"Git Fixes: The Current Branch Has No Upstream Branch"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e2cbf72dcbfaf9e81a8b6a38c1bd4220","name":"Felipe Boh\u00f3rquez","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-08-17-at-11.10.42-AM-150x150.png","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-08-17-at-11.10.42-AM-150x150.png","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/08\/Screen-Shot-2020-08-17-at-11.10.42-AM-150x150.png","caption":"Felipe Boh\u00f3rquez"},"description":"Felipe Boh\u00f3rquez is a Software Engineer and technical writer at Career Karma. He covers all things frontend and backend development.","url":"https:\/\/careerkarma.com\/blog\/author\/felipe-bohorquez\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/22838","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/86"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=22838"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/22838\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/12811"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=22838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=22838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=22838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}