{"thread":{"id":"37811","subject":"Feature Proposal: Track all branches from a given remote","startedAt":"2014-10-25T23:34:30Z","lastAt":"2014-10-26T11:18:33Z","messageCount":4,"participants":["Scott Johnson","brian m. carlson","Andreas Schwab"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"251050","messageId":"CAEFop41rvXCAawW7zWGzT251zWyyoMhQbg=5vtHzQrbk4W6D_Q@mail.gmail.com","threadId":"37811","inReplyTo":null,"subject":"Feature Proposal: Track all branches from a given remote","fromName":"Scott Johnson","fromEmail":"jaywir3@gmail.com","sentAt":"2014-10-25T23:34:30Z","receivedAt":"2014-10-25T23:34:30Z","isPatch":false,"sender":{"key":"jaywir3@gmail.com","avatar":"https://gravatar.com/avatar/9627800ffd11d60e29728cfb9ba14f64bff137ee7cad29b374213663ea060e70?d=mp&s=160"},"body":"Hello git experts:\n\nRecently, I've encountered the problem where I would like to set my\nlocal repository copy to track all branches on a given remote. There\ndoes not appear to be a switch for this in the git-branch command\ncurrently, however, I will admit that my somewhat limited\nunderstanding of the git-branch manpage might be causing me simply not\nto see it.\n\nIt seems as though this is a use case that some users of git encounter\nnow and then, as illustrated by this post:\n\nhttp://stackoverflow.com/a/6300386/281460\n\nI was thinking that it might be useful to add a new option to git\nbranch, perhaps something like:\n\ngit-branch --track-remote <remotename>\n\nWhere <remotename> specifies a given remote, and the command will\ntrack all branches remotes/<remotename>/* to refs/heads/*.\n\nSo, for example, if I were to run:\n\ngit-branch --track-remote origin\n\nand I had two branches on origin, master and maint, respectively,\nafter the command finishes, my local repo would now have two branches,\nmaster (set up to track origin/master), and maint (setup to track\norigin/maint).\n\nI'm not entirely sure how to handle naming conflicts, for example if\n'maint' already existed on another remote, and was set up to track\nfrom that remote previous to this invocation of the command.\n\nIf I were to start work on a patch, would there be any interest in\nthis feature, or are there reasons why it isn't currently implemented?\n\nThank you,\n\n~Scott Johnson\n"},{"id":"251051","messageId":"20141026001610.GK312818@vauxhall.crustytoothpaste.net","threadId":"37811","inReplyTo":"CAEFop41rvXCAawW7zWGzT251zWyyoMhQbg=5vtHzQrbk4W6D_Q@mail.gmail.com","subject":"Re: Feature Proposal: Track all branches from a given remote","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2014-10-26T00:16:10Z","receivedAt":"2014-10-26T00:16:10Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Sat, Oct 25, 2014 at 04:34:30PM -0700, Scott Johnson wrote:\n> Hello git experts:\n> \n> Recently, I've encountered the problem where I would like to set my\n> local repository copy to track all branches on a given remote. There\n> does not appear to be a switch for this in the git-branch command\n> currently, however, I will admit that my somewhat limited\n> understanding of the git-branch manpage might be causing me simply not\n> to see it.\n\nI don't know about a command line option for this, but I think there's a\nway to achieve what you're looking for.\n\n> So, for example, if I were to run:\n> \n> git-branch --track-remote origin\n> \n> and I had two branches on origin, master and maint, respectively,\n> after the command finishes, my local repo would now have two branches,\n> master (set up to track origin/master), and maint (setup to track\n> origin/maint).\n\nYou could do something like this in .git/config:\n\n[remote \"origin\"]\n  fetch = refs/heads/*:refs/heads/*\n\nYou won't be able to fetch if you would overwrite the current branch,\nthough.\n-- \nbrian m. carlson / brian with sandals: Houston, Texas, US\n+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only\nOpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187\n"},{"id":"251057","messageId":"CAEFop40qOPaq-6QrvNR0_MsgTv4K0jDNqb+m=BUZzFSXQ35YSQ@mail.gmail.com","threadId":"37811","inReplyTo":"20141026001610.GK312818@vauxhall.crustytoothpaste.net","subject":"Re: Feature Proposal: Track all branches from a given remote","fromName":"Scott Johnson","fromEmail":"jaywir3@gmail.com","sentAt":"2014-10-26T09:57:45Z","receivedAt":"2014-10-26T09:57:45Z","isPatch":false,"sender":{"key":"jaywir3@gmail.com","avatar":"https://gravatar.com/avatar/9627800ffd11d60e29728cfb9ba14f64bff137ee7cad29b374213663ea060e70?d=mp&s=160"},"body":"Hi Brian:\n\n> [remote \"origin\"]\n>   fetch = refs/heads/*:refs/heads/*\n\nYes, you're right, this works just fine as long as I move out from a\nbranch that's not in the remote in question, for example by doing:\n\ngit checkout -b nothing\ngit fetch\n\n- OR -\n\ngit pull\n\nDo you think there would be any interest in a patch that added this as\na simple command line option, though? I guess the idea of this patch\nthen would simply change this line in the .git/config file for the\nlength of the operation (and specified remote), execute the git pull\ncommand, and then reset the configuration after the command finished.\n(There really wouldn't be a need to affect the configuration on the\nfilesystem - simply the effective configuration used while git is\nrunning for this operation).\n\nThanks,\n\n~Scott\n"},{"id":"251058","messageId":"87a94j3wqe.fsf@igel.home","threadId":"37811","inReplyTo":"CAEFop40qOPaq-6QrvNR0_MsgTv4K0jDNqb+m=BUZzFSXQ35YSQ@mail.gmail.com","subject":"Re: Feature Proposal: Track all branches from a given remote","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2014-10-26T11:18:33Z","receivedAt":"2014-10-26T11:18:33Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Scott Johnson <jaywir3@gmail.com> writes:\n\n> Do you think there would be any interest in a patch that added this as\n> a simple command line option, though? I guess the idea of this patch\n> then would simply change this line in the .git/config file for the\n> length of the operation (and specified remote), execute the git pull\n> command, and then reset the configuration after the command finished.\n\nThere is no need to modify the configuration, you can pass the fetch\nspec on the command line.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"}]}