* Feature Proposal: Track all branches from a given remote
@ 2014-10-25 23:34 Scott Johnson
2014-10-26 0:16 ` brian m. carlson
0 siblings, 1 reply; 4+ messages in thread
From: Scott Johnson @ 2014-10-25 23:34 UTC (permalink / raw)
To: git
Hello git experts:
Recently, I've encountered the problem where I would like to set my
local repository copy to track all branches on a given remote. There
does not appear to be a switch for this in the git-branch command
currently, however, I will admit that my somewhat limited
understanding of the git-branch manpage might be causing me simply not
to see it.
It seems as though this is a use case that some users of git encounter
now and then, as illustrated by this post:
http://stackoverflow.com/a/6300386/281460
I was thinking that it might be useful to add a new option to git
branch, perhaps something like:
git-branch --track-remote <remotename>
Where <remotename> specifies a given remote, and the command will
track all branches remotes/<remotename>/* to refs/heads/*.
So, for example, if I were to run:
git-branch --track-remote origin
and I had two branches on origin, master and maint, respectively,
after the command finishes, my local repo would now have two branches,
master (set up to track origin/master), and maint (setup to track
origin/maint).
I'm not entirely sure how to handle naming conflicts, for example if
'maint' already existed on another remote, and was set up to track
from that remote previous to this invocation of the command.
If I were to start work on a patch, would there be any interest in
this feature, or are there reasons why it isn't currently implemented?
Thank you,
~Scott Johnson
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Feature Proposal: Track all branches from a given remote
2014-10-25 23:34 Feature Proposal: Track all branches from a given remote Scott Johnson
@ 2014-10-26 0:16 ` brian m. carlson
2014-10-26 9:57 ` Scott Johnson
0 siblings, 1 reply; 4+ messages in thread
From: brian m. carlson @ 2014-10-26 0:16 UTC (permalink / raw)
To: Scott Johnson; +Cc: git
[-- Attachment #1: Type: text/plain, Size: 1286 bytes --]
On Sat, Oct 25, 2014 at 04:34:30PM -0700, Scott Johnson wrote:
> Hello git experts:
>
> Recently, I've encountered the problem where I would like to set my
> local repository copy to track all branches on a given remote. There
> does not appear to be a switch for this in the git-branch command
> currently, however, I will admit that my somewhat limited
> understanding of the git-branch manpage might be causing me simply not
> to see it.
I don't know about a command line option for this, but I think there's a
way to achieve what you're looking for.
> So, for example, if I were to run:
>
> git-branch --track-remote origin
>
> and I had two branches on origin, master and maint, respectively,
> after the command finishes, my local repo would now have two branches,
> master (set up to track origin/master), and maint (setup to track
> origin/maint).
You could do something like this in .git/config:
[remote "origin"]
fetch = refs/heads/*:refs/heads/*
You won't be able to fetch if you would overwrite the current branch,
though.
--
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Feature Proposal: Track all branches from a given remote
2014-10-26 0:16 ` brian m. carlson
@ 2014-10-26 9:57 ` Scott Johnson
2014-10-26 11:18 ` Andreas Schwab
0 siblings, 1 reply; 4+ messages in thread
From: Scott Johnson @ 2014-10-26 9:57 UTC (permalink / raw)
To: Scott Johnson, git, sandals
Hi Brian:
> [remote "origin"]
> fetch = refs/heads/*:refs/heads/*
Yes, you're right, this works just fine as long as I move out from a
branch that's not in the remote in question, for example by doing:
git checkout -b nothing
git fetch
- OR -
git pull
Do you think there would be any interest in a patch that added this as
a simple command line option, though? I guess the idea of this patch
then would simply change this line in the .git/config file for the
length of the operation (and specified remote), execute the git pull
command, and then reset the configuration after the command finished.
(There really wouldn't be a need to affect the configuration on the
filesystem - simply the effective configuration used while git is
running for this operation).
Thanks,
~Scott
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Feature Proposal: Track all branches from a given remote
2014-10-26 9:57 ` Scott Johnson
@ 2014-10-26 11:18 ` Andreas Schwab
0 siblings, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2014-10-26 11:18 UTC (permalink / raw)
To: Scott Johnson; +Cc: git, sandals
Scott Johnson <jaywir3@gmail.com> writes:
> Do you think there would be any interest in a patch that added this as
> a simple command line option, though? I guess the idea of this patch
> then would simply change this line in the .git/config file for the
> length of the operation (and specified remote), execute the git pull
> command, and then reset the configuration after the command finished.
There is no need to modify the configuration, you can pass the fetch
spec on the command line.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-10-26 11:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-25 23:34 Feature Proposal: Track all branches from a given remote Scott Johnson
2014-10-26 0:16 ` brian m. carlson
2014-10-26 9:57 ` Scott Johnson
2014-10-26 11:18 ` Andreas Schwab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).