Ubuntu install git remote repository

 

ubuntu install git

# 安装git
sudo apt-get install git
# 查看git版本
git --version

Add the public key to the remote client library

1. Client generates key git

    ssh-keygen

2. Check the client public key (windows on /c/Users/admin/.ssh/id_dsa.pub public key, you can view by git)

   cat /c/Users/admin/.ssh/id_rsa.pub

3. Add the public key to the remote client library (copy the public key is added to the authorized_keys

 Note: The team is small (no more than 5 people) to each person's public key can be collected into the server /home/git/.ssh/authorized_keysfile, if a large team to manage public key can be used Gitosis


Create a user to run gitthe service

1. Create a remote git repository user account -git

  sudo adduser git

2. Disable shell login (for security reasons, git does not allow the user to create a login shell, by editing the /etc/passwdfile completion)

  sudo vim /etc/passwd

Figure:

The =>: git: x: 1000 : 1000: 1001: 1001: ,,,: / home / git: / bin / bash
to: git: x: 1000: 1000 : 1001: 1001: ,,,: / home / git: / usr / bin / git-shell


Initialization Git repository and set permissions

1. Create a bare warehouse (select a directory as a Git repository, it assumed to be /home/git/sampel.git)in the /home/gitinput command catalog:

  sudo git init --bare sample.git

2. git directory to add authority to write

  sudo chown -R git:git sample.git

Submit a remote cloning and remote library

Cloning the remote repository: git clone [email protected]: /home/git/sample.git

Submit to a remote repository

Note:

Git报错:insufficient permission for adding an object to repository database .git/objects

After building a local Git server, development machine push new code and found Git Tip: insufficient permission for adding an object to repository database .git / objects. The reason is: no repository directory write permissions, lead to a new file to upload. Change xx.git repository authority to order

Published 59 original articles · won praise 19 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_43507959/article/details/94493612