Quickly Deploy a Git Project on a Server With Ssh
So you have this brand new project my_project
of yours with your local Git
repository set up and you want to quickly make it available for others to clone
on your repository server.
All your projects are located in your server git.mycompany.com
under
/srv/git
. You’re using the user named git
to connect to your server with the
SSH private key located in ~/.ssh/git
.
Here is the quickiest way to deploy your projet:
You first add your SSH key to the SSH agent :
|
|
If the agent is not started, you need to execute first :
|
|
Then you create an empty Git bare repository on your server with the name of your project :
|
|
Then you add your newly created remote Git repository as the origin of your local repo :
|
|
You push your master branch to the remote repository :
|
|
Lastly, you make your local branch track your remote branch :
|
|
The last two steps can be done for any local branch you have that you want to push on the server.
You can test pulling from the server :
|
|
That’s it !