{"id":56,"date":"2011-10-03T22:55:38","date_gmt":"2011-10-04T05:55:38","guid":{"rendered":"http:\/\/www.lorrin.org\/blog\/?p=56"},"modified":"2012-03-16T23:28:18","modified_gmt":"2012-03-17T06:28:18","slug":"argumentless-git-pull-and-git-push","status":"publish","type":"post","link":"https:\/\/www.lorrin.org\/blog\/2011\/10\/03\/argumentless-git-pull-and-git-push\/","title":{"rendered":"Argumentless git pull and git push"},"content":{"rendered":"<p>Pulling and pushing with git can be a bit verbose.\u00a0 This post explains how to get from <code>git pull --rebase origin master<\/code> and <code>git push origin master<\/code> to just typing <code>git pull<\/code> and <code>git push<\/code>.<\/p>\n<h4>Rebase<\/h4>\n<p>First, set <em>rebase<\/em> for every new upstream branch (Why rebase? It <a title=\"git pull with rebase\" href=\"http:\/\/gitready.com\/advanced\/2009\/02\/11\/pull-with-rebase.html\">makes your history easier to understand<\/a>.)<\/p>\n<p><code>git config --global branch.autosetuprebase always <\/code><\/p>\n<p>This is explained in more detail (and with other helpful hints) in Mislav Marohni\u0107&#8217;s post <a href=\"http:\/\/mislav.uniqpath.com\/2010\/07\/git-tips\/\">A few git tips you didn&#8217;t know about<\/a>.<\/p>\n<h4>Tracking<\/h4>\n<p>Second, make <code>git push<\/code> only send the current branch to its matching upstream (aka tracking) branch. (Otherwise the default behavior is to push <em>all<\/em> branches that have the same name on both ends.)<\/p>\n<p><code>git config --global push.default upstream<\/code><\/p>\n<p>This is covered in some detail in Mark Longhair&#8217;s post <a href=\"http:\/\/longair.net\/blog\/2011\/02\/27\/an-asymmetry-between-git-pull-and-git-push\/\">An asymmetry between git pull and push<\/a>.<\/p>\n<p>On any existing branches, you can set up tracking by doing an explicit push:<\/p>\n<p><code>git push -u origin <em>branchname<\/em><\/code><\/p>\n<h4>Default refspec<\/h4>\n<p>At this point you should be set according to all the tutorials I came across. In my experience, however, this only works for branches other than master. A plain <code>git push<\/code> on master yields the error:<\/p>\n<p><code>fatal: The current branch master has multiple upstream branches, refusing to push.<\/code><\/p>\n<p>The solution is to set the default refspec for git push. I&#8217;m unclear on why this needed for master but not for other branches.<\/p>\n<p><code>git config remote.origin.push HEAD<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pulling and pushing with git can be a bit verbose.\u00a0 This post explains how to get from git pull &#8211;rebase origin master and git push origin master to just typing git pull and git push. Rebase First, set rebase for every new upstream branch (Why rebase? It makes your history easier to understand.) git config <a href='https:\/\/www.lorrin.org\/blog\/2011\/10\/03\/argumentless-git-pull-and-git-push\/' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[48],"tags":[20],"_links":{"self":[{"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/posts\/56"}],"collection":[{"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/comments?post=56"}],"version-history":[{"count":7,"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/posts\/56\/revisions"}],"predecessor-version":[{"id":158,"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/posts\/56\/revisions\/158"}],"wp:attachment":[{"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/media?parent=56"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/categories?post=56"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lorrin.org\/blog\/wp-json\/wp\/v2\/tags?post=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}