* Separate default push/pull?
@ 2010-02-11 16:36 David Abrahams
2010-02-11 18:57 ` Chris Packham
0 siblings, 1 reply; 8+ messages in thread
From: David Abrahams @ 2010-02-11 16:36 UTC (permalink / raw)
To: git
If I am collaborating mostly with one other person, I typically want to
pull from his publicly-readable repo and push to mine (on which I have
write permission). Is there any way to set things up so “git pull” and
“git push” without additional arguments will do this by default?
Thanks,
--
Dave Abrahams Meet me at BoostCon: http://www.boostcon.com
BoostPro Computing
http://www.boostpro.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Separate default push/pull?
2010-02-11 16:36 Separate default push/pull? David Abrahams
@ 2010-02-11 18:57 ` Chris Packham
2010-02-12 0:14 ` Jeff King
0 siblings, 1 reply; 8+ messages in thread
From: Chris Packham @ 2010-02-11 18:57 UTC (permalink / raw)
To: David Abrahams; +Cc: git
On Thu, Feb 11, 2010 at 11:36 AM, David Abrahams <dave@boostpro.com> wrote:
>
> If I am collaborating mostly with one other person, I typically want to
> pull from his publicly-readable repo and push to mine (on which I have
> write permission). Is there any way to set things up so “git pull” and
> “git push” without additional arguments will do this by default?
>
> Thanks,
>
> --
> Dave Abrahams Meet me at BoostCon: http://www.boostcon.com
> BoostPro Computing
> http://www.boostpro.com
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
Yes there is a way. I haven't used it myself but search this list and
you'll find plenty of references.
(disclaimer: the following is what I think you can do based on some
vague recollection and some man pages)
Taking a quick look at the git push --help you'll see the following
snippet of configuration.
[remote "<name>"]
url = <url>
pushurl = <pushurl>
push = <refspec>
fetch = <refspec>
so I think if you just add the pushurl to your .git/config should do
what you've asked
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git://git.kernel.org/pub/scm/git/git.git
pushurl = git://git.example.com/yourrepo.git
For your own sanity I suggest doing this by adding your repository as
a separate remote.
e.g.
git remote add yourrepo git://git.example.com/yourrepo.git
git push yourrepo master:refs/heads/master # the first time
git push yourrepo # subsequent times
There probably is a way to tell push to use something other than
"origin" by default but I don't know/can't find it.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Separate default push/pull?
2010-02-11 18:57 ` Chris Packham
@ 2010-02-12 0:14 ` Jeff King
2010-02-12 0:49 ` Junio C Hamano
0 siblings, 1 reply; 8+ messages in thread
From: Jeff King @ 2010-02-12 0:14 UTC (permalink / raw)
To: Chris Packham; +Cc: David Abrahams, git
On Thu, Feb 11, 2010 at 01:57:34PM -0500, Chris Packham wrote:
> Taking a quick look at the git push --help you'll see the following
> snippet of configuration.
>
> [remote "<name>"]
> url = <url>
> pushurl = <pushurl>
> push = <refspec>
> fetch = <refspec>
>
> so I think if you just add the pushurl to your .git/config should do
> what you've asked
>
> [remote "origin"]
> fetch = +refs/heads/*:refs/remotes/origin/*
> url = git://git.kernel.org/pub/scm/git/git.git
> pushurl = git://git.example.com/yourrepo.git
That's not quite what David wants, I think. That is a good recipe if you
have two ways of accessing the same repo (usually git:// for reading and
ssh for pushing). But if the two URLs actually point to _different_
repos, you will get some confusing results. For example, pushing to your
private repo will update the tracking branches in refs/remotes/origin/*
with values that do not match what is in the actual origin repository.
> git remote add yourrepo git://git.example.com/yourrepo.git
> git push yourrepo master:refs/heads/master # the first time
> git push yourrepo # subsequent times
>
> There probably is a way to tell push to use something other than
> "origin" by default but I don't know/can't find it.
I don't think there is currently a way to do what he wants. You can set
a default remote name by setting branch.*.remote, but that has two
problems:
1. It is also used to determine the upstream remote for pulling and
for calculating upstream tracking branches. So he probably wants to
leave it set as origin.
2. It would have to be set manually for every branch.
I think what he would need is a "push.defaultRemote" config option,
which universally overrides branch.*.remote for pushing.
-Peff
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Separate default push/pull?
2010-02-12 0:14 ` Jeff King
@ 2010-02-12 0:49 ` Junio C Hamano
2010-02-12 1:05 ` Jeff King
2010-02-12 2:32 ` David Abrahams
0 siblings, 2 replies; 8+ messages in thread
From: Junio C Hamano @ 2010-02-12 0:49 UTC (permalink / raw)
To: Jeff King; +Cc: Chris Packham, David Abrahams, git
Jeff King <peff@peff.net> writes:
> I think what he would need is a "push.defaultRemote" config option,
> which universally overrides branch.*.remote for pushing.
Or "branch.*.pushremote".
But does it really make sense to get changes from one place and send
changes to somewhere completely unrelated?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Separate default push/pull?
2010-02-12 0:49 ` Junio C Hamano
@ 2010-02-12 1:05 ` Jeff King
2010-02-12 5:57 ` Junio C Hamano
2010-02-12 2:32 ` David Abrahams
1 sibling, 1 reply; 8+ messages in thread
From: Jeff King @ 2010-02-12 1:05 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Chris Packham, David Abrahams, git
On Thu, Feb 11, 2010 at 04:49:26PM -0800, Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
>
> > I think what he would need is a "push.defaultRemote" config option,
> > which universally overrides branch.*.remote for pushing.
>
> Or "branch.*.pushremote".
That doesn't address my point 2, which is needing to set it up for every
branch.
> But does it really make sense to get changes from one place and send
> changes to somewhere completely unrelated?
It depends on your workflow. For git.git, your kernel.org repository is
my "origin", but I publish my state to a mirror for backup purposes (and
I don't publish for others to view, but I could very well do that, too).
I type "git push peff.net" and that is not too much trouble. Typing just
"git push" would be slightly more convenient, though.
In a distributed setup, I don't think it is that uncommon to not want to
push to the place you pull from. You are generally pulling and building
on somebody else's work, so if there is no central repo, you will be
pushing to somewhere that is not where you pulled it.
-Peff
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Separate default push/pull?
2010-02-12 0:49 ` Junio C Hamano
2010-02-12 1:05 ` Jeff King
@ 2010-02-12 2:32 ` David Abrahams
1 sibling, 0 replies; 8+ messages in thread
From: David Abrahams @ 2010-02-12 2:32 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jeff King, Chris Packham, David Abrahams, git
At Thu, 11 Feb 2010 16:49:26 -0800,
Junio C Hamano wrote:
>
> Jeff King <peff@peff.net> writes:
>
> > I think what he would need is a "push.defaultRemote" config option,
> > which universally overrides branch.*.remote for pushing.
>
> Or "branch.*.pushremote".
>
> But does it really make sense to get changes from one place and send
> changes to somewhere completely unrelated?
It's not unrelated; it's a publicly-readable clone of the source repo
to which I have write permission. After pushing changes there I send
a pull request to the owner of the source repo.
--
Dave Abrahams Meet me at BoostCon: http://www.boostcon.com
BoostPro Computing
http://www.boostpro.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Separate default push/pull?
2010-02-12 1:05 ` Jeff King
@ 2010-02-12 5:57 ` Junio C Hamano
2010-02-13 11:58 ` Jeff King
0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2010-02-12 5:57 UTC (permalink / raw)
To: Jeff King; +Cc: Chris Packham, David Abrahams, git
Jeff King <peff@peff.net> writes:
> In a distributed setup, I don't think it is that uncommon to not want to
> push to the place you pull from. You are generally pulling and building
> on somebody else's work, so if there is no central repo, you will be
> pushing to somewhere that is not where you pulled it.
You are probably right.
It still feels funny to see "git pull" and "git push" goes to different
places, but as long as that is what the user explicitly configures, that's
fine.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Separate default push/pull?
2010-02-12 5:57 ` Junio C Hamano
@ 2010-02-13 11:58 ` Jeff King
0 siblings, 0 replies; 8+ messages in thread
From: Jeff King @ 2010-02-13 11:58 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Chris Packham, David Abrahams, git
On Thu, Feb 11, 2010 at 09:57:54PM -0800, Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
>
> > In a distributed setup, I don't think it is that uncommon to not want to
> > push to the place you pull from. You are generally pulling and building
> > on somebody else's work, so if there is no central repo, you will be
> > pushing to somewhere that is not where you pulled it.
>
> You are probably right.
>
> It still feels funny to see "git pull" and "git push" goes to different
> places, but as long as that is what the user explicitly configures, that's
> fine.
By the way, I am a little iffy on the configuration I suggested. Even
though it matches David's workflow, it seems unintuitive to me that a
"push.defaultremote" variable would override what's in "branch.*.remote".
-Peff
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-02-13 11:58 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-11 16:36 Separate default push/pull? David Abrahams
2010-02-11 18:57 ` Chris Packham
2010-02-12 0:14 ` Jeff King
2010-02-12 0:49 ` Junio C Hamano
2010-02-12 1:05 ` Jeff King
2010-02-12 5:57 ` Junio C Hamano
2010-02-13 11:58 ` Jeff King
2010-02-12 2:32 ` David Abrahams
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).