2

I am honestly not sure how else to phrase the question but here is a better explanation.

We have a Git server at work with all our projects. Now obviously I have pulled these repositories onto my desktop machine at work. However, I can pull the repositories from my desktop machine at work to my home PC via a VPN connection.

When I finish working on something at home, I would like to push to my Desktop machine at work and not directly to the main server yet. How do I setup my work desktop machine so that I can push to it from home.

Currently when I try push to my work machine from home I get the following error:

git push remoteName branchName
fatal: 'remotePath' does not appear to be a git repository

1
  • It would be helpful to know the URL you used for the remote. Sep 22, 2011 at 20:23

1 Answer 1

3

Make sure remotePath points to an existing Git repository. Use git init to create one.

workpc$ mkdir ~/git
workpc$ git init --bare ~/git/myproject.git

homepc$ git remote add workpc [email protected]:git/myproject.git
homepc$ git push workpc master

Notes:

  • Do not push directly into a checked-out branch.

    • Most people push into a separate, 'bare' repository (as in the example), and do all editing on clones of it. (Yes, even if on the same machine.)

    • Or you can push into a separate branch with git push workpc master:fromhome, then at work git merge fromhome.

  • It is customary to append ".git" to bare repository names, like I did in the example above, but it's not a requirement.

2
  • You've pointed out something I have not done before, usually I just specify 'git init', I have never specified whether it should be --bare and I have never actually named a repository! Going to give that a go! Thanks!
    – StevenMcD
    Sep 22, 2011 at 20:28
  • 1
    @FailBoy: The differences are very minor: init gives you a working-tree and a .git subdirectory with Git data, and init --bare puts all Git data directly into the repository, without a working-tree. The latter is intended for "remotes", which you push to, pull from, but never edit directly. Similarly, giving a repository name to init does nothing more than create a new directory by that name, just like mkdir would. Sep 22, 2011 at 20:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .