Re: How to jump between two repositories ...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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ö

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux