As programmers, code version control is one of our daily operations. Git is one of the most popular version control tools currently. In team collaboration, we often need to add other members to our Git code base and give them corresponding permissions. This article will introduce how to pull new members in the Git code base.
In Git, we usually use the SSH protocol for access, so you first need to set SSH access permissions for new members. The specific steps are as follows:
~/.ssh/id_rsa.pub
file. Log in to your code base server and execute the following command in the terminal:
mkdir ~/.ssh echo [新成员的公钥] >> ~/.ssh/authorized_keys chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys
At this time, the public key of the new member has been added to your authorized_keys
file, new members can use the SSH protocol to access your Git code base.
After setting up SSH access, we need to add new members to the Git code repository. It should be noted at this time that new members cannot directly access your code base and need to be added as a team member.
Enter your Git code base and execute the following command in the terminal:
git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* git config --add remote.origin.push +refs/heads/*:refs/heads/* git remote add [新成员名] [新成员的git地址]
At this point, you have added the new member as a remote repository of the Git code base, but the new member has not Join your team. To add it as a team member, you need to log in to the web management interface of the Git code repository.
Log in to the web management interface of the Git code base and enter the team member management interface. First you need to invite new members to join your organization. Enter the new member's email address on the invitation page to invite them to join the organization. After receiving the invitation email, new members can click the link to join your organization.
After a new member joins the organization, you need to add them as a team member. On the team member management page, click Add Team Member and enter the new member's username to add them as a team member.
After a new member joins your team, you need to assign the corresponding permissions according to their required permissions. This kind of permission distribution is usually managed using Git's branching mechanism. Only members with corresponding permissions can operate on the branch.
To assign permissions in a Git code base, there are usually the following steps:
Create a new branch.
Enter the Git code base and use the following command to create a new branch:
git checkout -b [新分支名] git push --set-upstream origin [新分支名]
Add new members to the branch.
Enter the web management interface of the Git code base and add new members as collaborators in the new branch.
assign permissions.
In the Web management interface, assign write permissions to the corresponding branch to new members. For specific operations, please refer to the operating instructions document of the website corresponding to the Git code base.
Now, new members can access your Git code base through the SSH protocol and have corresponding permissions. In this way, collaborative development can be easily carried out and development efficiency can be improved.
In general, Git's code version control function provides a more convenient solution for multi-person collaboration, and implements operations such as branch permissions and member management through the Web management interface. Therefore, when we need to achieve multi-person collaboration, the use of Git is essential.
The above is the detailed content of How to pull members in git. For more information, please follow other related articles on the PHP Chinese website!