Article directory
1 Introduction
In the previous article, I explained some basic concepts and commonly used commands of Git. It's time to do a big thing - realize multi-person assistance development!
-
Environment: Centos7 cloud server
-
Code hosting platform: Gitee
Gitee is a domestic Git-based code hosting platform, similar to GitHub. It provides source code hosting, version control, project management, collaborative development, and more.
Gitee official website: https://gitee.com/
2. Creation of remote warehouse
After first logging in to Gitee, move the mouse to next to the avatar +
, and click to create a new warehouse
Go to the Create Warehouse page
Entering the name of the warehouse will automatically generate the path. If you are not satisfied with the generated path, you can change it manually. You can give a simple description of the warehouse
Whether the warehouse is open source, private, open source within the enterprise cannot be changed when it is just created, it can only be private
.gitignore
is a configuration file that specifies Git to ignore specific files or folders. You can tell Git which files should not be brought into version control by listing the names, patterns, or wildcards of the files or folders to ignore in the file.
For the initialization of the warehouse, you can choose according to your needs.
Let’s talk about the template here:
- Readme file: is a common document used to introduce the project to project contributors and users. It usually exists in the format of README.md, written using Markdown syntax. Provide project overview, usage instructions, installation guide, contribution guide, sample code and other information so that others can quickly understand and use your project.
- lssue template file: Issue template files usually exist in .md format, written using Markdown syntax, and contain some predefined fields and guidance information. When creating an Issue, you can fill in the corresponding information according to the field requirements in the template, such as problem description, reproduction steps, expected behavior, actual behavior, etc. (will be introduced later).
- Pull Request template file: PR template files usually exist in .md format, written in Markdown syntax, and contain some predefined fields and guidance information. When initiating a PR, you can fill in the corresponding information according to the field requirements in the template, such as PR description, modification content, test steps, related issues, etc.
The branch model can be selected according to the requirements.
(I did not initialize, I selected all when setting the template, and selected a single branch)
Click Create to complete the creation
You can see that the README file is generated to explain the description of the project
and a .gitee
directory
The .gitee directory contains lssue files and Pull Request files
Select lssues above to create lssue
The text here comes from the lssue.md file under .gitee, and a series of information can be set on the right.
The lssue file is a way for the person who finds the bug to communicate with the warehouse manager.
The PR file is actually a merge application form. Developers will not develop under the master branch. If the developer wants to submit the development directly to the master branch, he needs to write a merge application form, which requires the approval of the administrator before merging
3. Cloning of remote warehouse
There are four types of cloning remote warehouses to the local:
This article will introduce two methods: 1. HTTPS 2. SSH
Note: Set the warehouse as open source before cloning
3.1 Cloning using HTTPS
Copy the address under HTTPS
Use the command:
git clone [HTTPS网址]
Enter the cloned local warehouse to view
Add two commands:
# 查看远程仓库的名字(默认是origin)
git remote
# 查看对远程仓库的权限
git remote -v
3.2 Cloning using SSH
Configure the SSH public key, move the mouse to the avatar -> select Settings -> find the SSH public key in the security settings
.ssh
Then check if there is a directory in our server main directory
If so, check to see if there are any id_rsa(私钥)
and id_rsa.pub(公钥)
these two files in this directory, if not, you need to create themSSH KEY
Execute the following command:
ssh-keygen -t rsa -C "邮箱"
# 邮箱要与Gitee上的保持一致
Execute the command, if you need to fill in something, just press Enter, and the following interface will appear to indicate that the configuration is successful
View the file at this time , and these two files .ssh
will appearid_rsa(私钥)
id_rsa.pub(公钥)
Use cat
the command to view id_rsa.pub(公钥)
this file, and then copy the string of information that appears.
Paste it into Gitee and confirm it.
Copy the SSH address of the repository:
Then execute git clone
the command
4. Push from remote warehouse
After cloning to the local warehouse, configure the local warehouseuser.name 和 user.email
The command is as follows:
git config [user.name/user.email] [值]
The username and email address here should also be consistent with those on Gitee
Git's workflow is usually as follows:
- Modify (add, modify, delete) files in the workspace.
- Add the modified file to the staging area, use
git add
the command. - Submit the files in the temporary storage area to the version library and use
git commit
the command. - Push the local submission to the remote warehouse, use
git push
the command
The first three steps have been introduced in the previous article, friends who are not familiar with it can read the article I wrote before.
git push [远程仓库名] [本地分支]:[远程分支]
# 如果本地分支和远程分支相同,可以省略":[远程分支]"
This effect shows that the push has been successful, you can enter the remote warehouse to check and verify
5. Pulling from the remote warehouse
Gitee is a platform for multi-person assisted development. If the code in the remote warehouse is newer than the code in our local warehouse, we need to pull the latest code from the remote warehouse
The following commands can be used:
git pull [远程仓库名] [远程分支]:[本地分支]
If the above situation occurs, it means that the remote warehouse has been pulled successfully.
This is the end of the article, thank you for watching!