I’ve done something like following:
(1) clone a remote git repository to local host
local# git clone http://www.foo.com foo
(2) add another project on a ssh host(bar) as the second remote repository
local# git remote add bar ssh://bar/home/project
local# git fetch bar
(3) done something stupid on the ssh host(bar):
bar# rm -rf /home/project
Could you please tell me how can I recover project on the ssh host(bar) from my local copy, so other developer on the ssh host can continue their work, and I can run ‘git fetch bar’ to get their commit, just like I didn’t do anything wrong to their ssh host, i.e. undo all I did to host bar. thanks a lot.
UPDATE:
bar# mkdir -p /home/project && cd /home/project && git init --bare
local# git branch remote show bar
local# git push bar bar/master:refs/heads/master
local# git push bar bar/branch1:refs/heads/branch1
local# git push bar bar/branch2:refs/heads/branch2
You can setup the remote host as a new git repository and then push to it.
This blog goes over how to do it:
Toolman Tim – Setting up a new remote git repository
assuming you still have bar setup as a remote repository, essentially:
refspec is frequently just the simple name of the branch in the local repository so:
See the git push manpage for a detailed treatment of what qualifies for a refspec. The EXAMPLES section is particularly helpful in understanding more advanced respecs