Git server installation

Install git package on your server (google install git server OS_NAME)

# ssh into your server and run the following commands:

$ sudo adduser git
$ su git
$ mkdir .ssh

#If you haven’t already done so already generate ssh keys on your local client machine:

$ ssh-keygen -t rsa -C “”

# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
# Enter file in which to save the key (/path_to_your_home_folder/.ssh/id_rsa): [Press enter]…

# copy contents of into memory
# back on your server server
$ vi ~/.ssh/authorized_keys
# press letter i and paste (CTRL + V or CMD +V)
# press : (colon) then type wq and enter

# Now it’s time to create some git repo(s) where you’ll push your code:
# Firstly, repo creation on your server:

$cd ~
$ mkdir project.git
$ cd project.git
$ git –bare init

# Back on your client create new git local repo:

$ mkdir project.git
$ cd project.git
$ git init

# Commit your current structure or files you add:

$ git add .
$ git commit -m ‘initial commit’

# add remote repo on your server so local git knows where to push:
$ git remote rm origin
$ git remote add origin git@gitserver:/opt/git/project.git
$ git push origin master

Note: if you are logged in as different user than git on your client you’ll be asked for a password each time you push/fetch/pull from the server. You can set one by running on the server:

#sudo passwd git

Otherwise it should not prompt for any.

1 thought on “Git server installation

  1. Pingback: Date time pickerDavid Sadowski

Leave a Reply

Your email address will not be published. Required fields are marked *