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.

Was it helpful?

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 triads instructions, something like this:

  1. Make a --bare repository somewhere. This is going to be the staging ground. Call it something useful, like bareRepository or something.
  2. You have a repository with some work in it. In that repository (on server or laptop), add bareRepository to your list of remotes: git remote add <name> <url>.
  3. git push your work from the repository in (2) to bareRepository. That'll ensure that bareRepository is up-to-date and whatnot.
  4. Because you can't work out of bareRepository, clone it again on which ever computer does not have a working repository (server or laptop). Because you're cloning bareRepository, git will treat bareRepository as the origin; you can git push origin and git pull origin to your hearts content, without messing up a repository with a work tree.
  5. Once you've set up the two working repositories (one on laptop, one on server) and a --bare repository (on either laptop or server), you should be able to sync your work happily:
    • do some work
    • git commit the work
    • git push origin - get the work to the bare repo
    • On the other computer: git pull origin to update your branch.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top