{"id":22166,"date":"2014-07-10T11:03:50","date_gmt":"2014-07-10T09:03:50","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=22166"},"modified":"2014-07-10T11:03:50","modified_gmt":"2014-07-10T09:03:50","slug":"git-branch-names-support-forward-slashes","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2014\/07\/10\/git-branch-names-support-forward-slashes\/","title":{"rendered":"Git branch names support forward slashes"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p>Oh. My. God! \u00a0I&#8217;ve been using git for years now and I only learned this today &#8211; git branch names support forward slashes! How awesome is that?! \u00a0You can do things like this:<\/p>\n<pre class=\"brush: bash; light: true; title: ; notranslate\" title=\"\">\r\n$ git checkout -b feature\/foobar\r\n<\/pre>\n<p>Grouping branches like this is much easier indeed!<\/p>\n<p>I came across this while reading CakeDC&#8217;s <a href=\"http:\/\/www.cakedc.com\/plugin-standard\">CakePHP Plugin Standard<\/a>. \u00a0Searching around to find more details, I see that there are a few potential issues with this naming convention, as tools occasionally break (composer, IDEs, etc). \u00a0 However, these problems are fixed by tool vendors. \u00a0Looking into it even further, I found the following description in the book &#8220;<a href=\"http:\/\/www.amazon.com\/Version-Control-Git-collaborative-development\/dp\/1449316387\">Version Control with Git: Powerful tools and techniques for collaborative software development<\/a>&#8221; (<a href=\"http:\/\/books.google.com.cy\/books?id=qIucp61eqAwC&amp;pg=PA91&amp;lpg=PA91&amp;dq=git+branch+name+support+slash&amp;source=bl&amp;ots=jeUOLp_pEE&amp;sig=0sly7OBdIqzD2yfNmVmWFduDM38&amp;hl=en&amp;sa=X&amp;ei=hkm-U5b5I4P20gXXmIHgAQ&amp;ved=0CEAQ6AEwBQ#v=onepage&amp;q=git%20branch%20name%20support%20slash&amp;f=false\">Google Books preview<\/a>):<\/p>\n<blockquote><p><strong>Dos and Don&#8217;ts in Branch Names<\/strong><\/p>\n<p>Branch names must conform to a few simple rules.<\/p>\n<ul>\n<li>You can use the forward slash (\/) to create a hierarchical name scheme. \u00a0However, the name cannot end with a slash.<\/li>\n<li>The name cannot start with a minus sign (-).<\/li>\n<li>No slash-separated component can begin with a dot (.). \u00a0A branch name such as <em>feature\/.new<\/em> is invalid.<\/li>\n<li>The name cannot contain two consecutive dots (..) anywhere.<\/li>\n<li>Further, the name cannot contain:\n<ul>\n<li>Any space or other whitespace character<\/li>\n<li>A character that has special meaning to Git, including the tilde (~), caret (^), colon (:), question mark (?), asterisk (*), and open bracket ([).<\/li>\n<li>An ASCII control character, which is any byte with a value lower than \\040 octal, or the DEL character (\\177 octal)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>These branch name rules are enforced by the <em>git check-ref-format<\/em> plumbing command, and they are designed to ensure that each branch name is both easily typed and usable as a filename within the .git directory and scripts.<\/p><\/blockquote>\n<p>So, as you can see, you aren&#8217;t even limited to the single forward slash. Even things like this work just fine:<\/p>\n<pre class=\"brush: bash; light: true; title: ; notranslate\" title=\"\">\r\n$ git checkout -b Leonid\/ideas\/feature\/foobar\r\n<\/pre>\n<p>But remember, just because you CAN do something, doesn&#8217;t necessarily mean you SHOULD. \u00a0Have a look at <a href=\"http:\/\/stackoverflow.com\/questions\/273695\/git-branch-naming-best-practices\">this StackOverflow discussion<\/a> about git branch naming best practices for more understanding on what you should and shouldn&#8217;t do.<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>Oh. My. God! \u00a0I&#8217;ve been using git for years now and I only learned this today &#8211; git branch names support forward slashes! How awesome is that?! \u00a0You can do things like this: $ git checkout -b feature\/foobar Grouping branches like this is much easier indeed! I came across this while reading CakeDC&#8217;s CakePHP Plugin &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2014\/07\/10\/git-branch-names-support-forward-slashes\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Git branch names support forward slashes<\/span><\/a><\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_links_to":"","_links_to_target":""},"categories":[1,18,62],"tags":[3069,2265,1673,1588,1330],"keyring_services":[],"class_list":["post-22166","post","type-post","status-publish","format-standard","hentry","category-general","category-programming","category-technology","tag-best-practices","tag-git","tag-software-engineering","tag-version-control","tag-web-development"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":16691,"url":"https:\/\/mamchenkov.net\/wordpress\/2012\/09\/07\/smartgit-the-easy-to-use-githgsvn-client\/","url_meta":{"origin":22166,"position":0},"title":"SmartGit \u2014 The Easy-to-Use Git+Hg+SVN Client","author":"Leonid Mamchenkov","date":"September 7, 2012","format":"link","excerpt":"SmartGit \u2014 The Easy-to-Use Git+Hg+SVN Client Personally, I prefer command line tools that allow me the greatest flexibility and control. \u00a0However there are many people who feel more comfortable in graphical environments. \u00a0For them, SmartGit looks like a good option. SmartGit is an easy-to-use graphical user interface for Git, Mercurial\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26685,"url":"https:\/\/mamchenkov.net\/wordpress\/2016\/09\/12\/git-history-of-a-source-code-line\/","url_meta":{"origin":22166,"position":1},"title":"git: history of a source code line","author":"Leonid Mamchenkov","date":"September 12, 2016","format":false,"excerpt":"git is one of those tools that no matter how much you know about it, there is an infinite supply of new things to learn. \u00a0Here's a handy bit I've discovered recently, thanks to this StackOverflow comment: Since Git 1.8.4, git log has -L to view the evolution of a\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27374,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/02\/27\/moving-files-with-commit-history-from-one-git-repository-to-another\/","url_meta":{"origin":22166,"position":2},"title":"Moving files with commit history from one git repository to another","author":"Leonid Mamchenkov","date":"February 27, 2017","format":false,"excerpt":"I've searched for this before, and I'm sure I'll do that again (although the need is not that frequent), so here it goes. \u00a0It is possible to move files from one git repository to another, preserving commit history. \u00a0The following links provide a few examples of how to do this:\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":24504,"url":"https:\/\/mamchenkov.net\/wordpress\/2015\/07\/23\/code-sleuthing-with-git\/","url_meta":{"origin":22166,"position":3},"title":"Code Sleuthing with Git","author":"Leonid Mamchenkov","date":"July 23, 2015","format":false,"excerpt":"Code Sleuthing with Git has a handy tip for searching through git logs: [code light=\"true\"] -S <string> Look for differences that change the number of occurrences of the specified string (i.e. addition\/deletion) in a file. [\/code]","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":17655,"url":"https:\/\/mamchenkov.net\/wordpress\/2013\/01\/09\/git-separating-folder-into-different-repository-with-history\/","url_meta":{"origin":22166,"position":4},"title":"Git : separating folder into different repository, with history","author":"Leonid Mamchenkov","date":"January 9, 2013","format":false,"excerpt":"First things first. \u00a0If you don't use git for version control yet, stop right now and go plan your migration. \u00a0You'll thank me later. \u00a0Now. \u00a0A few days ago I had a tricky problem. \u00a0A chunk of code that was initially all over the project has been refactored into a\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":25046,"url":"https:\/\/mamchenkov.net\/wordpress\/2015\/12\/12\/fixing-mistakes-in-git\/","url_meta":{"origin":22166,"position":5},"title":"Fixing mistakes in Git","author":"Leonid Mamchenkov","date":"December 12, 2015","format":false,"excerpt":"Linux.com reiterates over the ways to fix and undo mistakes using Git version control software. \u00a0Seasoned git users will probably know all of these already, but since I have to explain these things to git newcomers, I thought I'd have it handy somewhere here.","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"git","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2015\/12\/git.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/22166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=22166"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/22166\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=22166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=22166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=22166"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=22166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}