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

From One-Eyed Man Wiki
Jump to navigation Jump to search
(Adding clone info)
 
Line 4: Line 4:
On server, as user git:
On server, as user git:
  <pre>
  <pre>
  mkdir my_project.git
  mkdir project.git
  cd my_project.git
  cd project.git
  git --bare init</pre>
  git --bare init</pre>
On client:
On client:
  <pre>
  <pre>
  mkdir my_project
  mkdir project
  cd my_project
  cd project
  touch .gitignore
  touch .gitignore
  git init
  git init
  git add .
  git add .
  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/project.git
  git push origin master</pre>
  git push origin master</pre>



Latest revision as of 22:32, 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 project.git
 cd project.git
 git --bare init

On client:

 mkdir project
 cd project
 touch .gitignore
 git init
 git add .
 git commit -m "Initial commit"
 git remote add origin youruser@yourserver.com:/path/to/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

On client, as regular user:

 cd ~/git
 git clone git:/home/git/project.git