Reputation: 15327
I have two machines: remote and local. I want remote to be my main repository that I can push to from local.
I have a current project
that lives on remote that I would like to store into git's repository.
Since the files were originally on remote and I also needed a bare repository that I could push to on remote, this was a little tricky. The procedure is essentially a bootstrap until I have the bare directory up.
The sequence I used to set-up and test, as suggested by Paolo Capriotti in his short answer below:
/home/me/depot/project
git push origin master
to post to bare repo on remotegit pull
to pull from bare repoAn even simpler sequence would involve ignoring the local directory completely. First set up the working and bare repo on remote and then finally, on local, clone from the bare repo on remote.
I have tried the following:
edit a file on local
fails
remote: error: refusing to update checked out branch: refs/heads/master remote: error: By default, updating the current branch in a non-bare repository remote: error: is denied, because it will make the index and work tree inconsistent remote: error: with what you pushed, and will require 'git reset --hard' to match remote: error: the work tree to HEAD.
So I start over: rm -rf .git directory on remote, rm -rf on local.
I try creating a bare directory on remote:
fails
fatal: This operation must be run in a work tree
What series of steps do I have to go through so I can push from the local machine to the remote machine, starting with a project
but no repositories?
I prefer the depot in a /home/me/depot
directory on remote if possible.
Does that mean I need both a bare and a non-bare repository on remote?
Upvotes: 2
Views: 1099
Reputation: 4072
Create a bare repository on remote with git init --bare
, don't add any files yet. Create a repository on local, add your files, then push to remote.
Upvotes: 4