Categories
Tools

Create a local and remote git repository pair

1. From the client connect to the remote server: e.g. ssh admin@192.168.1.72

2. Create an empty folder on the server for the repository.
mkdir repo.git (In place of “repo” use your project name)

3. On the server, go on the repository folder: cd repo.git

4. Initialise the empty remote repository as bare.
git init –bare

5. On the client, go to the project folder: cd localcode

6. Initialise the local git repository.
git init

7. Next, link the local client repository with the remote repository. The remote repository is given the short name “origin”.
e.g. git remote add origin ssh://christos@192.168.1.72/volume1/homes/christos/git-repos/repo.git

8. Place the local files under version control.
git add .

9. Now I can commit the local files to the local repository.
git commit -a -m ‘Initializing repository’

10. Finally, push the local master branch to the “origin” remote repository.
git push origin master