For GitHub to collaborate with multiple people, it is necessary for the collaborators to have their own GitHub accounts and add collaborators to the GitHub library that requires multiple people.
1. Add collaborator
Add collaborator: there is the option to add a collaborator in the settings option in the GitHub library.
There are two ways to add a collaborator: one is to use the email address of the collaborator, and the other is to use the user name to search.
If you don’t find him with his email address, his GitHub account sets his email address as private, and you can search with his account name.
Collaborators need to modify their mailbox settings to enable them to search for them using their mailboxes.
To modify mailbox settings:
Click “keep my email address private” to select it. This is to set my email address as private. Now we need to set my email address as development. Click the button before “keep my email address private”,Become unchecked。
Then configure the personal information to select the mailbox, as shown in the figure: select the mailbox you want to open
Collaborator added successfully
After clicking, you can use the email to search, and then add a collaborator. The collaborator will receive an email. The collaborator needs to agree to become the collaborator of this GitHub library.
After the collaborator is added, the collaborator can push the changes to the GitHub library.
2. Cooperation authority of inspection collaborators
The next step is the collaborator’s operation to verify whether the collaborator can push to the GitHub library.
Right click on the desktop to open git bash here command tool
Collaborators first need to clone the GitHub Library:
Git clone gi[email protected]github.com: own user name / GitHub library name.git
Let’s take a look at the branches
Run the command to show that there is only one branch, and there is only one master branch when the GitHub library is cloned locally. We need to create a new branch locally to connect with the GitHub remote branch. In the previous two chapters, we have pushed the local dev branch to the far end, which has two branches. If you have any questions, please refer to the first two chapters.
Create a new dev branch: git checkout - B dev
Next, connect the dev branch on GitHub:
git branch --set-upstream-to origin/<branch-name>
Now modify the ss.html file, such as adding several div tags to the file.
Submit for modification: Git add ss.html Git commit -m””
Push under the dev branch:
git push origin dev
Push succeeded, that is to say, the branch connection we made before was successful, and we have now submitted the modification of the collaborator to the GitHub remote library.
3. Verify changes pushed by collaborators
Now, we use GitHub library owners or other collaborators to verify the results of the push.
The collaborator just now has pushed the dev branch to GitHub. Let’s pull it to see if the modification is successfully pushed to GitHub.
Pull: git pull
This account has not yet been connected with the local dev branch and the remote dev branch. We have implemented the connection command above. We can connect by ourselves. Enter git branch — set upstream to origin / < branch name > in the command tool to connect before we can pull the modification of the dev branch.
After connecting, execute the GIT pull command:
Now open the ss.html file to see if any changes have occurred, and you’ll see that they did. The changes made by the collaborators are indeed pushed to the GitHub library. We have successfully implemented git’s multi-user collaboration.
If you have any questions, please leave a message below. If there is any mistake in the article, please correct it.