git clone from local to remote

To answer your first question, yes, you can. Suppose the remote directory is ssh://user@host/home/user/repo. This must be a git repository, create that with git init --bare or scp your local repo.git (can be created with git clone) directory to remote. Then do:

git remote add origin ssh://user@host/home/user/repo
git push --all origin

This will push all locally-existing branches to the remote repository.

To get to your next question, you should be able to do the same thing by using a different set of commands. Try these:

$ cd /var/www  # or wherever
$ mkdir somesite
$ cd somesite/
$ git init
$ git --bare update-server-info
$ git config receive.denycurrentbranch ignore
$ cat > hooks/post-receive
#!/bin/sh
git checkout -f
^D
$ chmod +x hooks/post-receive

You would, of course, run the remote/push commands above after this step. You may have to check out a specific branch after doing so, so that the “somesite” clone on the server actually knows which branch to follow. From then on out, pushing to that repository should trigger a re-checkout of that branch.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)