* How to jump between two repositories ...
@ 2007-12-05 5:59 g2
2007-12-05 6:11 ` Shawn O. Pearce
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: g2 @ 2007-12-05 5:59 UTC (permalink / raw)
To: git
Hello all,
I am currently working on some code at the office that I also want to
work with at home. Seems like a good candidate for git. So I created a
repository at work and did a "git clone" at home. I've run into some
strange behaviour that I don't understand and would appreciate if
someone can clarify for me.
Imagine this scenario. At work:
git init
edit test.c
git add test.c
git commit
Then at home:
git clone <work git url>
edit test.c
git commit -a
git push
At this point, I wanted to push my changes back to my work repository
so I can continue work the next day. So at home, I did a git push. I
expect that my work repository has the newest material, but I find
that when I do "git status" at work the next day, it tells me that my
test.c is "modified" and has already staged it for commit. I need to
do a "git reset" followed by "git checkout" to update my work folder
to the latest stuff.
Totally different from my expectation of the repository knowing that
it is out of date and then kindly suggesting that I should do a "git
update" of some sort. What piece of understanding am I missing to
properly "get" what is going on here, and how am I supposed to
properly work with this setup?
Thanks for any help.
Gerald.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to jump between two repositories ...
2007-12-05 5:59 How to jump between two repositories g2
@ 2007-12-05 6:11 ` Shawn O. Pearce
2007-12-05 6:14 ` J. Bruce Fields
2007-12-05 6:20 ` Väinö Järvelä
2 siblings, 0 replies; 10+ messages in thread
From: Shawn O. Pearce @ 2007-12-05 6:11 UTC (permalink / raw)
To: g2; +Cc: git
g2 <gerald.gutierrez@gmail.com> wrote:
> At this point, I wanted to push my changes back to my work repository
> so I can continue work the next day. So at home, I did a git push. I
> expect that my work repository has the newest material, but I find
> that when I do "git status" at work the next day, it tells me that my
> test.c is "modified" and has already staged it for commit. I need to
> do a "git reset" followed by "git checkout" to update my work folder
> to the latest stuff.
Oddly enough, this question is asked so frequently that it is
answered in the GitFaq on the GitWiki:
http://git.or.cz/gitwiki/GitFaq#head-b96f48bc9c925074be9f95c0fce69bcece5f6e73
--
Shawn.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to jump between two repositories ...
2007-12-05 5:59 How to jump between two repositories g2
2007-12-05 6:11 ` Shawn O. Pearce
@ 2007-12-05 6:14 ` J. Bruce Fields
2007-12-05 8:45 ` Andreas Ericsson
2007-12-05 6:20 ` Väinö Järvelä
2 siblings, 1 reply; 10+ messages in thread
From: J. Bruce Fields @ 2007-12-05 6:14 UTC (permalink / raw)
To: g2; +Cc: git
On Tue, Dec 04, 2007 at 09:59:57PM -0800, g2 wrote:
> Hello all,
>
> I am currently working on some code at the office that I also want to work
> with at home. Seems like a good candidate for git. So I created a
> repository at work and did a "git clone" at home. I've run into some
> strange behaviour that I don't understand and would appreciate if someone
> can clarify for me.
>
> Imagine this scenario. At work:
> git init
> edit test.c
> git add test.c
> git commit
>
> Then at home:
> git clone <work git url>
> edit test.c
> git commit -a
> git push
You'll be much happier at this point if you ssh into work and then git
pull from home....
> At this point, I wanted to push my changes back to my work repository so I
> can continue work the next day. So at home, I did a git push. I expect that
> my work repository has the newest material, but I find that when I do "git
> status" at work the next day, it tells me that my test.c is "modified" and
> has already staged it for commit. I need to do a "git reset" followed by
> "git checkout" to update my work folder to the latest stuff.
>
> Totally different from my expectation of the repository knowing that it is
> out of date and then kindly suggesting that I should do a "git update" of
> some sort. What piece of understanding am I missing to properly "get" what
> is going on here, and how am I supposed to properly work with this setup?
Git doesn't support pushing to any branch that's checked out somewhere.
--b.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to jump between two repositories ...
2007-12-05 5:59 How to jump between two repositories g2
2007-12-05 6:11 ` Shawn O. Pearce
2007-12-05 6:14 ` J. Bruce Fields
@ 2007-12-05 6:20 ` Väinö Järvelä
2007-12-05 6:44 ` g2
2 siblings, 1 reply; 10+ messages in thread
From: Väinö Järvelä @ 2007-12-05 6:20 UTC (permalink / raw)
To: g2; +Cc: git
On Dec 5, 2007, at 07:59, g2 wrote:
> I am currently working on some code at the office that I also want
> to work with at home. Seems like a good candidate for git. So I
> created a repository at work and did a "git clone" at home. I've run
> into some strange behaviour that I don't understand and would
> appreciate if someone can clarify for me.
>
> Imagine this scenario. At work:
> git init
> edit test.c
> git add test.c
> git commit
>
> Then at home:
> git clone <work git url>
> edit test.c
> git commit -a
> git push
>
> At this point, I wanted to push my changes back to my work
> repository so I can continue work the next day. So at home, I did a
> git push. I expect that my work repository has the newest material,
> but I find that when I do "git status" at work the next day, it
> tells me that my test.c is "modified" and has already staged it for
> commit. I need to do a "git reset" followed by "git checkout" to
> update my work folder to the latest stuff.
Did you clone a bare repository and push to it?
Here is an excerpt from Git User's Manual:
"Note that the target of a "push" is normally a bare repository. You
can also push to a repository that has a checked-out working tree, but
the working tree will not be updated by the push. This may lead to
unexpected results if the branch you push to is the currently checked-
out branch!"
So to push to your work repository, you should create an intermediary
repository between the work and home repositories. You can create it
by running:
$ git clone --bare /git/work/ /git/work.git/
Then you clone normally from the bare repository and pushing to it
works fine. After you have pushed your changes to the bare repository,
you'll have to pull them to the work repository to get the updates,
just like you would do with any public repository.
Another option would be to pull from your home repository to the work
repository, if you can access your home computer from the work computer.
--
Väinö
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to jump between two repositories ...
2007-12-05 6:20 ` Väinö Järvelä
@ 2007-12-05 6:44 ` g2
2007-12-05 6:57 ` Steven Grimm
2007-12-05 7:32 ` Väinö Järvelä
0 siblings, 2 replies; 10+ messages in thread
From: g2 @ 2007-12-05 6:44 UTC (permalink / raw)
To: Väinö Järvelä; +Cc: git
What I am gathering from this is that I can use git in two ways: 1) as
"just another svn" bare git repository, or 2) only pull and don't
push, because push causes confusion. I'd be happy to only ever use
pull, but I have one machine behind a firewall and can't pull. I can
push to a bare git repository like the svn model, but then I would
just use svn. What's the value of "push" then?
On 4-Dec-07, at 10:20 PM, Väinö Järvelä wrote:
> On Dec 5, 2007, at 07:59, g2 wrote:
>
>> I am currently working on some code at the office that I also want
>> to work with at home. Seems like a good candidate for git. So I
>> created a repository at work and did a "git clone" at home. I've
>> run into some strange behaviour that I don't understand and would
>> appreciate if someone can clarify for me.
>>
>> Imagine this scenario. At work:
>> git init
>> edit test.c
>> git add test.c
>> git commit
>>
>> Then at home:
>> git clone <work git url>
>> edit test.c
>> git commit -a
>> git push
>>
>> At this point, I wanted to push my changes back to my work
>> repository so I can continue work the next day. So at home, I did a
>> git push. I expect that my work repository has the newest material,
>> but I find that when I do "git status" at work the next day, it
>> tells me that my test.c is "modified" and has already staged it for
>> commit. I need to do a "git reset" followed by "git checkout" to
>> update my work folder to the latest stuff.
>
> Did you clone a bare repository and push to it?
>
> Here is an excerpt from Git User's Manual:
> "Note that the target of a "push" is normally a bare repository. You
> can also push to a repository that has a checked-out working tree,
> but the working tree will not be updated by the push. This may lead
> to unexpected results if the branch you push to is the currently
> checked-out branch!"
>
> So to push to your work repository, you should create an
> intermediary repository between the work and home repositories. You
> can create it by running:
> $ git clone --bare /git/work/ /git/work.git/
>
> Then you clone normally from the bare repository and pushing to it
> works fine. After you have pushed your changes to the bare
> repository, you'll have to pull them to the work repository to get
> the updates, just like you would do with any public repository.
>
> Another option would be to pull from your home repository to the
> work repository, if you can access your home computer from the work
> computer.
>
> --
> Väinö
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to jump between two repositories ...
2007-12-05 6:44 ` g2
@ 2007-12-05 6:57 ` Steven Grimm
2007-12-05 7:32 ` Väinö Järvelä
1 sibling, 0 replies; 10+ messages in thread
From: Steven Grimm @ 2007-12-05 6:57 UTC (permalink / raw)
To: g2; +Cc: Väinö Järvelä, git
On Dec 4, 2007, at 10:44 PM, g2 wrote:
> What I am gathering from this is that I can use git in two ways: 1)
> as "just another svn" bare git repository, or 2) only pull and don't
> push, because push causes confusion. I'd be happy to only ever use
> pull, but I have one machine behind a firewall and can't pull. I can
> push to a bare git repository like the svn model, but then I would
> just use svn. What's the value of "push" then?
You can push. Just don't push to a checked-out branch. I do exactly
what you're describing and it works fine. It looks something like this:
server% git checkout mybranch
server% edit somefile.c
server% git commit
laptop% git checkout mybranch
laptop% git pull
(with a pull configuration that pulls server's mybranch into
laptop's)
laptop% edit somefile.c
laptop% git commit
laptop% git push server mybranch:laptop/mybranch
server% git checkout mybranch
server% git rebase laptop/mybranch
Presto, ready to go. The trick is to push into a branch that's
different from the one that's checked out, then rebase on top of that
on the remote side after the push.
Yeah, it'd be nicer if you could just push to the checked-out branch
directly (and there are hooks to let you do that) but this is only
slightly awkward and it's easy once you've done it a few times.
-Steve
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to jump between two repositories ...
2007-12-05 6:44 ` g2
2007-12-05 6:57 ` Steven Grimm
@ 2007-12-05 7:32 ` Väinö Järvelä
1 sibling, 0 replies; 10+ messages in thread
From: Väinö Järvelä @ 2007-12-05 7:32 UTC (permalink / raw)
To: g2; +Cc: git
On Dec 5, 2007, at 08:44, g2 wrote:
> What I am gathering from this is that I can use git in two ways: 1)
> as "just another svn" bare git repository, or 2) only pull and don't
> push, because push causes confusion. I'd be happy to only ever use
> pull, but I have one machine behind a firewall and can't pull. I can
> push to a bare git repository like the svn model, but then I would
> just use svn. What's the value of "push" then?
I guess the value over svn, is in the excellent tools that Git
provides (such as rebase, bisect and merging). And that you can
develop offline and still retain the individual commits.
And you could use Steven Grimms solution, but I guess with that, you
need to be careful to not leave your servers working tree on any of
your laptop/ branch if you might push to one.
--
Väinö
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to jump between two repositories ...
2007-12-05 6:14 ` J. Bruce Fields
@ 2007-12-05 8:45 ` Andreas Ericsson
2007-12-05 15:28 ` g2
0 siblings, 1 reply; 10+ messages in thread
From: Andreas Ericsson @ 2007-12-05 8:45 UTC (permalink / raw)
To: J. Bruce Fields; +Cc: g2, git
J. Bruce Fields wrote:
> On Tue, Dec 04, 2007 at 09:59:57PM -0800, g2 wrote:
>> Hello all,
>>
>> I am currently working on some code at the office that I also want to work
>> with at home. Seems like a good candidate for git. So I created a
>> repository at work and did a "git clone" at home. I've run into some
>> strange behaviour that I don't understand and would appreciate if someone
>> can clarify for me.
>>
>> Imagine this scenario. At work:
>> git init
>> edit test.c
>> git add test.c
>> git commit
>>
>> Then at home:
>> git clone <work git url>
>> edit test.c
>> git commit -a
>> git push
>
> You'll be much happier at this point if you ssh into work and then git
> pull from home....
>
>> At this point, I wanted to push my changes back to my work repository so I
>> can continue work the next day. So at home, I did a git push. I expect that
>> my work repository has the newest material, but I find that when I do "git
>> status" at work the next day, it tells me that my test.c is "modified" and
>> has already staged it for commit. I need to do a "git reset" followed by
>> "git checkout" to update my work folder to the latest stuff.
>>
>> Totally different from my expectation of the repository knowing that it is
>> out of date and then kindly suggesting that I should do a "git update" of
>> some sort. What piece of understanding am I missing to properly "get" what
>> is going on here, and how am I supposed to properly work with this setup?
>
> Git doesn't support pushing to any branch that's checked out somewhere.
>
Yes it does. It just supports it badly. If there is a work-tree connected to
the receiving repository and that work-tree is pristine, it would be safe and
sane to write the newly pushed changes to the connected working tree.
We do all our integration fixups by pushing to repositories with work-trees,
simply because it's ridiculously inconvenient to add the infrastructure to
pull to those repos from each individual developer. In that scenario, pushing
to a checked out branch is highly useful and perfectly safe.
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to jump between two repositories ...
2007-12-05 8:45 ` Andreas Ericsson
@ 2007-12-05 15:28 ` g2
2007-12-05 16:19 ` Andreas Ericsson
0 siblings, 1 reply; 10+ messages in thread
From: g2 @ 2007-12-05 15:28 UTC (permalink / raw)
To: Andreas Ericsson; +Cc: git
How do you safely push to the repository? Even if my receiving
repository is pristine (the last command I do is a commit), after I
push into it, some files in the work-tree are effectively out of date
and git says so by thinking they are modified and staged for commit.
My original set of example commands illustrates this. What set of
commands do you use to avoid the problem?
On 5-Dec-07, at 12:45 AM, Andreas Ericsson wrote:
>
> Yes it does. It just supports it badly. If there is a work-tree
> connected to
> the receiving repository and that work-tree is pristine, it would be
> safe and
> sane to write the newly pushed changes to the connected working tree.
>
> We do all our integration fixups by pushing to repositories with
> work-trees,
> simply because it's ridiculously inconvenient to add the
> infrastructure to
> pull to those repos from each individual developer. In that
> scenario, pushing
> to a checked out branch is highly useful and perfectly safe.
>
> --
> Andreas Ericsson andreas.ericsson@op5.se
> OP5 AB www.op5.se
> Tel: +46 8-230225 Fax: +46 8-230231
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How to jump between two repositories ...
2007-12-05 15:28 ` g2
@ 2007-12-05 16:19 ` Andreas Ericsson
0 siblings, 0 replies; 10+ messages in thread
From: Andreas Ericsson @ 2007-12-05 16:19 UTC (permalink / raw)
To: g2; +Cc: git
post
top-
don't
Please
g2 wrote:
>
> How do you safely push to the repository? Even if my receiving
> repository is pristine (the last command I do is a commit), after I push
> into it, some files in the work-tree are effectively out of date and git
> says so by thinking they are modified and staged for commit. My original
> set of example commands illustrates this. What set of commands do you
> use to avoid the problem?
>
Vanilla git-push, ofcourse. I just make sure to run "git reset --hard" in
the receiving repo before using anything in it. Granted, it's "safe"
because I know I never want to use any changes from those repos and not.
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-12-05 16:19 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-05 5:59 How to jump between two repositories g2
2007-12-05 6:11 ` Shawn O. Pearce
2007-12-05 6:14 ` J. Bruce Fields
2007-12-05 8:45 ` Andreas Ericsson
2007-12-05 15:28 ` g2
2007-12-05 16:19 ` Andreas Ericsson
2007-12-05 6:20 ` Väinö Järvelä
2007-12-05 6:44 ` g2
2007-12-05 6:57 ` Steven Grimm
2007-12-05 7:32 ` Väinö Järvelä
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).