
{"id":1637,"date":"2015-06-02T23:22:56","date_gmt":"2015-06-03T03:22:56","guid":{"rendered":"http:\/\/www.ikriv.com\/blog\/?p=1637"},"modified":"2015-06-02T23:22:56","modified_gmt":"2015-06-03T03:22:56","slug":"the-joy-of-git","status":"publish","type":"post","link":"https:\/\/ikriv.com\/blog\/?p=1637","title":{"rendered":"The joy of git"},"content":{"rendered":"<p>Trying to move an SVN repository to git, I discovered a couple of interesting facts:<\/p>\n<p><b><code><a href=\"http:\/\/git-scm.com\/docs\/git-clone\">git clone<\/a><\/code> does not really clone<\/b>.<\/p>\n<p>It only copies one branch, so the resulting repository is not identical to the original. Creating a real clone with all branches is possible, but it requires adding a local branch for each remote branch:<\/p>\n<p><code>branch --track somename origin\/somename<\/code><\/p>\n<p>Beware of counterfeits: if you do <code>branch --track somename <font color=\"red\">(bad)<\/font><\/code> or <code>branch -track origin\/somename origin\/somename <font color=\"red\">(bad)<\/font><\/code>, this won&#8217;t do what you want. Also, you will get an error if you will try to track an already tracked branch like <code>master<\/code>.<\/p>\n<p><b><code><a href=\"http:\/\/git-scm.com\/docs\/git-pull\">git pull --all<\/a><\/code> and <code><a href=\"http:\/\/git-scm.com\/docs\/git-push\">git push --all<\/a><\/code> are not symmetrical<\/b><\/p>\n<p><code>git pull --all<\/code> means &#8220;all remotes&#8221;. It pulls a single branch from all remotes (and it looks like it pulls tags as well). A typical repository has exactly one remote called &#8220;origin&#8221;.<\/p>\n<p><code>git push --all<\/code> means &#8220;all branches&#8221;. It pushes all branches to a single remote. To add to the confusion, it does not push tags.<\/p>\n<p>As far as I can tell, there is no way to tell &#8220;pull&#8221; to pull all branches, as well as there is no way to tell &#8220;push&#8221; to push to all remotes.<\/p>\n<p><b>git pull does not remove references to deleted remote branches<\/b><\/p>\n<p>Let&#8217;s say you pulled a branch <code>foo<\/code> from origin, and then someone else deleted it from the remote repository. Your local repository will still have a dangling reference to <code>origin\/foo<\/code>. Pulling from origin does not change anything. To get rid of the dangling reference you must cast a special spell:<\/p>\n<p><code>git remote prune origin<\/code><\/p>\n<p>Fun stuff!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Trying to move an SVN repository to git, I discovered a couple of interesting facts: git clone does not really clone. It only copies one branch, so the resulting repository <a href=\"https:\/\/ikriv.com\/blog\/?p=1637\" class=\"more-link\">[&hellip;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[21],"tags":[],"class_list":["entry","author-ikriv","post-1637","post","type-post","status-publish","format-standard","category-git"],"_links":{"self":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1637","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1637"}],"version-history":[{"count":0,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1637\/revisions"}],"wp:attachment":[{"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1637"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1637"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ikriv.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1637"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}