Difference between revisions of "Git -- new repository setup"

From One-Eyed Man Wiki
Jump to navigation Jump to search
Line 6: Line 6:
  mkdir my_project.git
  mkdir my_project.git
  cd my_project.git
  cd my_project.git
  git --bare init
  git --bare init</pre>
</pre>
On client:
On client:
  <code>mkdir my_project
  <pre>
mkdir my_project
  cd my_project
  cd my_project
  touch .gitignore
  touch .gitignore
Line 16: Line 16:
  git commit -m "Initial commit"
  git commit -m "Initial commit"
  git remote add origin youruser@yourserver.com:/path/to/my_project.git
  git remote add origin youruser@yourserver.com:/path/to/my_project.git
  git push origin master</code>
  git push origin master</pre>


  <code>[https://stackoverflow.com/questions/2337281/how-do-i-do-an-initial-push-to-a-remote-repository-with-git<nowiki>]</nowiki></code>
  <code>[https://stackoverflow.com/questions/2337281/how-do-i-do-an-initial-push-to-a-remote-repository-with-git<nowiki>]</nowiki></code>


== Clone existing repository ==
== Clone existing repository ==
<pre>
git clone git:/home/git/project.git</pre>

Revision as of 22:25, 9 September 2023

Set up new repository

Note that the URL in my case is defined via ~/.ssh/config. I write it directly into .../[repo]/.git/config.

On server, as user git:

 mkdir my_project.git
 cd my_project.git
 git --bare init

On client:

 mkdir my_project
 cd my_project
 touch .gitignore
 git init
 git add .
 git commit -m "Initial commit"
 git remote add origin youruser@yourserver.com:/path/to/my_project.git
 git push origin master
[https://stackoverflow.com/questions/2337281/how-do-i-do-an-initial-push-to-a-remote-repository-with-git]

Clone existing repository

 git clone git:/home/git/project.git