Git installation:
$ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
$ yum install git
Copy the code
- Yum install git
Create a user:
[root@VM_16_3_centos /]# useradd newuser [root@VM_16_3_centos /]# passwd newuser Changing password for user newuser. New password: BAD PASSWORD: The password is a palindrome Retype new password: passwd: all authentication tokens updated successfully.Copy the code
- Create a user
- Enter the password twice ok
Create a group and add users to the group:
[root@VM_16_3_centos /]# groupadd group01
[root@VM_16_3_centos /]# usermod -G group01 newuser
Copy the code
- Usermod -g Group name User name: belongs to the current group
- Usermod -a -g Group name User name: belongs to multiple groups at the same time
Create git repository:
[root@VM_16_3_centos /]# mkdir -p /git/test/app.git
[root@VM_16_3_centos /]# git init --bare /git/test/app.git
Initialized empty Git repository in /git/test/app.git/
Copy the code
- Create git repositories
- Initialize the factory library
Add permission:
[root@VM_16_3_centos /]# chown -R newuser:newuser /git/test/app.git
Copy the code
- Add permissions to the factory repository
To disable SSH login to the server:
chsh newuser-s /sbin/nologin
Copy the code
Restore newuser login to server:
- 1: Run vim /etc/passwd
- 2: Find the line where newuser resides and change the last line from /sbin/nologin to /bin/bash
Client clone library:
$git clone [email protected]: / git/test/app. Git Cloning into 'app... [email protected]'s password: Warning: You appear to have verification an empty repository.Copy the code
- After installing Git on the client
- Open a folder
- Right click Git GUI Here
- Input: git clone [email protected]: / git/test/app. The git
- Enter the password
- ok
Add cache upload and download:
$ mkdir abc
$ git add abc
$ git commit -m "ss"
$ git push
Copy the code
To sum up:
Establish project members
- 1) Log in to the server with an administrator account and set up a system account for each project member according to their situation. The account belongs to group001. Assume that the project member account is user001.
# useradd -m -g group001 -r user001 // Create a new account. The account name is user001 and belongs to group001. # passwd user001 // Set the initial password for the new account
- Enter the password twice to create a system account.
- 2) Follow the above method to set up system accounts for other members of the project team.
The administrator creates an empty warehouse
- The administrator needs to set up an empty repository for the project team and import the legacy code after the repository is set up.
$git = $git = $git = $git = $git = $git # CHGRP -r group001 /git/project // # chmod — R 775 /git/project // set repository permissions: owner and group can read and write, other groups can read only
Project member User001 started working on Linux
- 1) User001, a project team member, starts working on his Linux computer.
- 2) Use the system account user001 for remote Shell login.
- 3) Set the initial account and email address
# git config — global user.email [email protected]
- 4) Clone the remote repository
# git clone [email protected]: / git/project
- Enter the password to complete the clone
- The system may prompt that the clone is an empty warehouse, this is normal.
5) # cd project
- 6) Add/delete/modify files in the project directory.
8) # git commit -a -m “new commit” // commit changes to a local repository copy 9) # git push origin master // Push the changes to the remote repository (that is, our server), and remember to specify the branch master
- 10) At this point, commit changes to the server.
- 11) If you want to get the latest version from the server, use the pull directive.
# git pull
- ok
The article continues to be updated!