{"thread":{"id":"42872","subject":"Feature request for automatic worktree checkout","startedAt":"2016-07-18T17:43:10Z","lastAt":"2016-07-19T05:46:50Z","messageCount":3,"participants":["Ehsan Azarnasab","Junio C Hamano","Jacob Keller"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"291660","messageId":"CADWjqk40KK=AuKqqdpKjkBuUvhQb4k4fMR4bPfdo8JkGRs-Y9w@mail.gmail.com","threadId":"42872","inReplyTo":null,"subject":"Feature request for automatic worktree checkout","fromName":"Ehsan Azarnasab","fromEmail":"azarnasab@gmail.com","sentAt":"2016-07-18T17:42:57Z","receivedAt":"2016-07-18T17:43:10Z","isPatch":false,"sender":{"key":"azarnasab@gmail.com","avatar":null},"body":"Currently if I have a branch checked out in a work-tree, git-checkout\nwill show this error message when checking out that branch:\n\n$ git checkout master\nfatal: 'master' is already checked out at '/home/dashesy/development/feature'\n\nIt would be very useful to instead of this error just change the\ncurrent working directory, so git checkout would become a `cd` command\n\nEhsan\n"},{"id":"291664","messageId":"xmqqpoqakd8s.fsf@gitster.mtv.corp.google.com","threadId":"42872","inReplyTo":"CADWjqk40KK=AuKqqdpKjkBuUvhQb4k4fMR4bPfdo8JkGRs-Y9w@mail.gmail.com","subject":"Re: Feature request for automatic worktree checkout","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-07-18T18:33:23Z","receivedAt":"2016-07-18T18:33:31Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ehsan Azarnasab <azarnasab@gmail.com> writes:\n\n> Currently if I have a branch checked out in a work-tree, git-checkout\n> will show this error message when checking out that branch:\n>\n> $ git checkout master\n> fatal: 'master' is already checked out at '/home/dashesy/development/feature'\n>\n> It would be very useful to instead of this error just change the\n> current working directory, so git checkout would become a `cd` command\n\nThat is an understandable thing to want from 10,000ft view, but it\nwould not be something Git, or any external command that is spawned\nby the shell for that matter, can address.  You'd need to teach the\nshell to cooperate.\n"},{"id":"291707","messageId":"CA+P7+xoeO43A+BdkdzeMpuKh=B7Ma+JVq3WR5bsX8XGYxPdmxg@mail.gmail.com","threadId":"42872","inReplyTo":"xmqqpoqakd8s.fsf@gitster.mtv.corp.google.com","subject":"Re: Feature request for automatic worktree checkout","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2016-07-19T05:46:25Z","receivedAt":"2016-07-19T05:46:50Z","isPatch":false,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Mon, Jul 18, 2016 at 11:33 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Ehsan Azarnasab <azarnasab@gmail.com> writes:\n>\n>> Currently if I have a branch checked out in a work-tree, git-checkout\n>> will show this error message when checking out that branch:\n>>\n>> $ git checkout master\n>> fatal: 'master' is already checked out at '/home/dashesy/development/feature'\n>>\n>> It would be very useful to instead of this error just change the\n>> current working directory, so git checkout would become a `cd` command\n>\n> That is an understandable thing to want from 10,000ft view, but it\n> would not be something Git, or any external command that is spawned\n> by the shell for that matter, can address.  You'd need to teach the\n> shell to cooperate.\n> --\n\nYou could implement this for yourself as a shell function sort of, by\nwrapping git, but it's a bit crazy, something like:\n\nfunction git() {\n  # check if first argument is checkout, otherwise exec git\n  # check second argument, and parse git-worktree to determine if it\nis checked out\n  # if so, just cd into the directory\n  # else exec git normally.\n}\n\nI'll leave actual implementations to the user. Note at least for BASH,\nyou need to actually do this as a function alias.\n\nThanks,\nJake\n"}]}