git después de init y push? Necesito clonar uno nuevo?

I am not a skilled. in ssh server, I create :

$ mkdir project.git
$ cd project.git
$ git --bare init

and then in my pc:

$ cd myproject
$ git init
$ git add .
$ git commit -m 'initial commit'
$ git remote add origin git@gitserver:/opt/git/project.git
$ git push origin master

all thing is ok. in old days (i learn from svn), i remove myproject and then clone ,and start my work.

git clone git@gitserver:/opt/git/project.git

can i start work in myproject folder?

preguntado el 15 de noviembre de 13 a las 08:11

¿Cuál es tu pregunta exactamente? -

can i start work in myproject work? -

2 Respuestas

You don't need to remove and clone your project after push. It's already ready to be worked on, and linked to your remote.

To shorten things, once the repository is created on the server you could have done directly :

$ cd myproject
$ git clone git@gitserver:/opt/git/project.git
$ git add .
$ git commit -m 'initial commit'
$ git push origin master

Porque un git clone establece automáticamente origin to the repository which was cloned.

respondido 15 nov., 13:09

¿Cómo es git clone supposed to succeed when the project doesn't exist on the server, yet? - Aarón Digulla

I assume that of course creation has happened, making it clearer - carlosb

I think the point of this question is: "How do I create a new repo on the remote server y attach my local copy at the same time?" - Aarón Digulla

I think one small change in your steps would get you what you want:

$ cd myproject
$ git init
$ git add .
$ git commit -m 'initial commit'
$ git remote add origin git@gitserver:/opt/git/project.git
$ git push -u origin master

Notice in the last step the -u flag. That sets master para rastrear el master branch of the upstream repository. After doing this, your repository will have the same configuration as if you had cloned it.

respondido 15 nov., 13:16

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.