git pull fatal error server repo
Question
My goal is to set up a repo on my lab server, which I can clone on my laptop via ssh. I still want a working copy on the server. Here is what I did:
server:
mkdir myProject
git --init
(add some files and commit them so it' isn't empty)
git clone --bare ~/myProject/.git/ ~/git/myrepo.git
laptop:
git clone erin@labserver.edu:/home/erin/myrepo.git
git add file1
git commit
git push
server:
git pull
then I get this error:
fatal: Where do you want to fetch from today?
Do you have an idea of what could be wrong? I tried following the branching/ staging/rebasing directions here, but it didn't fix the problem. Also
git pull origin master
didn't fix it either.
Solution
I've followed the steps you've listed, and I can't reproduce the error that you're getting (fatal: Where do you want to fetch from today?
). However, if you've followed the steps that you've written out in the question, server
doesn't have any remote repositories - git pull
won't work, because server
doesn't have any remotes to pull from. I think that is the cause of the error you're getting.
At the moment, you've got three repositories: on server: myProject
, myRepo
, and on laptop myRepo
(clone from server
). If my understanding of the question is correct, you want to use myProject
(on server
) and myRepo
(on Laptop
) to work from. I assume you've got myRepo
(on server
) as a staging ground that you can git push
and git pull
from; you've done that correctly, because you've set it up as a --bare
repository, which is a smart move.
If you follow triad
's instructions in his answer, you'll end up with two repositories: server
, which is a --bare
repository, and laptop
. If you're comfortable re-setting up your repositories, I would follow triad
s instructions, something like this:
- Make a
--bare
repository somewhere. This is going to be the staging ground. Call it something useful, likebareRepository
or something. - You have a repository with some work in it. In that repository (on
server
orlaptop
), addbareRepository
to your list of remotes:git remote add <name> <url>
. git push
your work from the repository in (2) tobareRepository
. That'll ensure thatbareRepository
is up-to-date and whatnot.- Because you can't work out of
bareRepository
, clone it again on which ever computer does not have a working repository (server
orlaptop
). Because you're cloningbareRepository
, git will treatbareRepository
as theorigin
; you cangit push origin
andgit pull origin
to your hearts content, without messing up a repository with a work tree. - Once you've set up the two working repositories (one on
laptop
, one onserver
) and a--bare
repository (on eitherlaptop
orserver
), you should be able to sync your work happily:- do some work
git commit
the workgit push origin
- get the work to the bare repo- On the other computer:
git pull origin
to update your branch.