I have an existing Git repository on my local machine. I would like to move that repository to my web server, then git clone
on my local machine to check out my repository from the server. I'm planning on then developing on my local machine and pushing updates back to the server. I can ssh from my local machine to the server, but not vice versa. How should I go about this? I think git bundle should be used somehow, though when I tried to git clone
my bundle on my server, I got a "warning: remote HEAD refers to nonexistent ref, unable to checkout" error. My local machine is running OS X, the server is running Linux.
views:
29answers:
2
A:
How about this:
local> cd my_repo.git local> git remote add origin user@host:/path/to/my_repo.git local> git config branch.master.remote origin local> git congig branch.master.merge refs/heads/master local> git push origin master
That will send the data from your local repo to your server. Then do this:
local> cd .. local> git clone user@host:/path/to/my_repo.git my_repo2.git
Then you will have cloned from the server. When satisfied, you can get rid of the original repo, and possibly rename the second one.
Paul Beckingham
2010-10-08 22:38:01
+3
A:
On the Linux server, in a new directory do:
git init --shared --bare
Then on your local machine:
git remote add origin server:path/to/repo
git push origin master
After that, the server will have a full copy of the repository, and you will be able to push and pull to and from it. There's no need to check out another clone from the server when you've already got one locally.
Greg Hewgill
2010-10-08 22:39:24
Upon doing `git push origin master`, I get a long error that starts with "Total 0 (delta 0), reused 0 (delta 0)remote: error: refusing to update checked out branch: refs/heads/masterremote: error: By default, updating the current branch in a non-bare repository". The only contents of my repos on the Linux server is ". .. .git HEAD branches config description hooks info objects refs", which is what the `git init --shared --bare` command created. I'm using git 1.7.1.1 on both computers.
Sarah Vessels
2010-10-09 19:37:16
Whoop, never mind! I got it to work just now. I hadn't actually created a new directory on the Linux server, I had just removed what I thought were all of its contents before running the `git init...` command. Creating a new directory, `git init...`ing it, changing to use that origin from my local repos, and then pushing worked.
Sarah Vessels
2010-10-09 19:42:45