GIT – setting git server ubuntu

beberapa hal yang dibutuhkan untuk install git server adalah

– user (biasanya git)

– git


# pada komputer server, ip 192.168.0.216

# add user git
user@server:~$ sudo adduser git

# install git
user@server:~$ sudo apt-get install git

# restrict shell untuk user git
user@server:~$ which git-shell
/usr/bin/git-shell
user@server:~$ sudo nano /etc/shells
# add /usr/bin/git-shell
# save
# change shch
user@server:~$ sudo shch git
# and input your git-shell path

# masuk ke home user git
user@server:~$ su git
git@server:~$ cd

# buat dir .ssh dan file authorized keys didalamnya
git@server:~$ mkdir .ssh && chmod 700 .ssh && cd .ssh
git@server:~$ touch authorized_keys && chmod 600 authorized_keys

# buat folder untuk repository
git@server:~$ mkdir repo && cd repo
git@server:~/repo$ mkdir pro1.git && cd pro1.git/

# set git repository
git@server:~/repo/pro1.git$ git init --bare
Initialized empty Git repository in /home/git/repo/pro1.git/

...

pada komputer client (g3n1k)


g3n1k@n43s:~$ ssh-keygen -C "g3n1k@yahoo.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/g3n1k/.ssh/id_rsa):

....
g3n1k@n43s:~$ cat ~/.ssh/id_rsa.pub | ssh git@192.168.0.216 "cat >> ~/.ssh/authorized_keys"

g3n1k@n43s:~$ mkdir -p tmp/test && cd tmp/test

g3n1k@n43s:~/tmp/test$ git init
Initialized empty Git repository in /home/g3n1k/tmp/test/.git/
g3n1k@n43s:~/tmp/test$ git add .
g3n1k@n43s:~/tmp/test$ touch gw.txt
g3n1k@n43s:~/tmp/test$ nano gw.txt
g3n1k@n43s:~/tmp/test$ git add gw.txt
g3n1k@n43s:~/tmp/test$ git commit -m 'initial commit'
g3n1k@n43s:~/tmp/test$ git remote add origin git@192.168.0.216:/home/git/repo/pro1.git
g3n1k@n43s:~/tmp/test$ git push origin master

# lakukan test commit ke 2 pada
g3n1k@n43s:~/tmp/test$ nano gw.txt
g3n1k@n43s:~/tmp/test$ git add gw.txt
g3n1k@n43s:~/tmp/test$ git commit -m 'second commit'
g3n1k@n43s:~/tmp/test$ git push origin master
Enter passphrase for key '/home/g3n1k/.ssh/id_rsa':

# lakukan test clone repository dari server
g3n1k@n43s:~/tmp$ mkdir git2 && cd git2
g3n1k@n43s:~/tmp/git2$ git clone git@192.168.0.216:/home/git/repo/pro1.git
Cloning into 'pro1'...
Enter passphrase for key '/home/g3n1k/.ssh/id_rsa':
...
g3n1k@n43s:~/tmp/git2$ ls
pro1

git-shell-clone
http://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-private-git-server-on-a-vps

Published by

G3n1k

just to remember what i had known :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s