Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to git push to remote if remote does not exist at all

Tags:

git

If remote (using ssh) does not contain the git repository, is it still possible to copy the local repository to remote and setup the remote tracking without manually copying the files using scp and doing then followed by a git clone?

like image 292
Ryan Avatar asked Jul 08 '12 10:07

Ryan


1 Answers

You do need to setup the repository on the remote, but you shouldn't copy the files manually. At the very least, you don't get the history with it.

First, ssh to your remote and do this:

mkdir your_repo.git
cd your_repo.git
git init --bare

The .git in directory name is completely optional. The --bare option makes the repository without index and is therefore pushable.

You then go back to your local repository and add the remote:

git remote add remote_name [email protected]:path/to/your_repo.git

You are all set. All you need to do now is:

git push remote_name
like image 131
Shahbaz Avatar answered Oct 05 '22 23:10

Shahbaz