{"id":3684,"date":"2017-09-16T19:23:53","date_gmt":"2017-09-16T16:23:53","guid":{"rendered":"http:\/\/mummila.net\/nuudelisoppa\/?p=3684"},"modified":"2017-09-16T19:23:53","modified_gmt":"2017-09-16T16:23:53","slug":"get-git_work_tree-from-the-post-checkout-hook","status":"publish","type":"post","link":"https:\/\/mummila.net\/nuudelisoppa\/2017\/09\/16\/get-git_work_tree-from-the-post-checkout-hook\/","title":{"rendered":"Get GIT_WORK_TREE from the post-checkout hook"},"content":{"rendered":"<p>I was crafting a post-checkout hook and wanted to do something depending on the absolute path of <code>$GIT_WORK_TREE<\/code> in the current environment. In git 2.7.4 (and up to 2.4.14) at least, that environment variable was set to &#8220;.&#8221; when inside the post-checkout hook, which was a little unhelpful in this case. So I spent some time trying to google why and coming up empty.<\/p>\n<p>Here&#8217;s where you&#8217;re entitled to laugh at my over-thinking this.<\/p>\n<p>Since I&#8217;m in the work tree already (.) when inside the hook, the absolute path is the current working directory, or $PWD. No need to fiddle with GIT_WORK_TREE at all.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was crafting a post-checkout hook and wanted to do something depending on the absolute path of $GIT_WORK_TREE in the current environment. In git 2.7.4 (and up to 2.4.14) at least, that environment variable was set to &#8220;.&#8221; when inside the post-checkout hook, which was a little unhelpful in this case. So I spent some [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3684","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts\/3684","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/comments?post=3684"}],"version-history":[{"count":1,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts\/3684\/revisions"}],"predecessor-version":[{"id":3685,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts\/3684\/revisions\/3685"}],"wp:attachment":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/media?parent=3684"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/categories?post=3684"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/tags?post=3684"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}