Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a remote git repo from local folder

Tags:

git

I think there must be an easier way to do this. Right now I find myself following these steps:

On the remote:

mkdir my_repo
cd my_repo
git init --bare

Then locally:

mv my_repo old_my_repo
git clone ssh://myserver/my_repo
mv old_my_repo/* my_repo
rmdir old_my_repo
cd my_repo
git add .
git commit -m 'foo'
git push origin master

Is there some shortcut?

like image 658
pguardiario Avatar asked Dec 30 '12 02:12

pguardiario


2 Answers

Unfortunately almost all steps are necessary, even though locally you can avoid to recreate the repo by cloning it.

Just init the repo and add a remote

cd my_repo
git init
git remote add origin ssh://myserver/my_repo
git add .
git commit -m "Initial commit"
git push -u origin master

Note that the -u option will add a tracking reference, so later on you can simply type git push instead of git push origin master.

like image 97
Gabriele Petronella Avatar answered Oct 11 '22 01:10

Gabriele Petronella


The answer from Gabriele almost worked for me.

Before the git push -u origin master a git init --bare my_repo needs to be called in the directory that ssh:://myserver points to.

like image 22
Doug Park Avatar answered Oct 11 '22 01:10

Doug Park