In the software development process, using Git for version control has become a very popular way. Gitee is a code hosting platform similar to GitHub, which can help us better manage our code. In some cases, we may need to create a private repository to save our code, which requires using Gitee's private repository function.
In this article, we will introduce how to create a private repository on Gitee and upload code to the repository.
Step 1: Register a Gitee account
Before using Gitee, you need to register an account on its official website. The process is very simple and requires only your email address and password. Once registration is complete, you can log in and visit Gitee's homepage.
Step 2: Create a Private Repository
To create a private repository, follow these steps:
At this time, you have successfully created a private warehouse.
Step 3: Generate SSH public key
In order to push code to Gitee's private repository, you need to connect using the SSH protocol. You need to generate an SSH public key and add it to your Gitee account. Here are the steps on how to generate an SSH public key:
Open a terminal and enter the following command:
ssh-keygen
Step 4: Add the public key to Gitee
After you generate the SSH public key, you need to add it to your Gitee account. Please follow these steps:
Step 5: Push the code to the private repository
To push the code to the private repository you created, follow these steps:
Open the terminal and enter the following command:
git clone git@gitee.com:[user name]/[warehouse name].git
where [user name] is you For your Gitee username, [repository name] is the name of the private repository you just created.
Go into your code directory and execute the following command:
git add .
git commit -m "This is a commit message"
Push code to a private warehouse:
git push origin master
Among them, origin represents the alias of the remote warehouse, and master is the default master branch.
Now, you have successfully pushed the code to the private warehouse. Only you and those authorized by you have access to these codes. If you need to add more collaborators, you can add their usernames in the Gitee repository settings page.
Conclusion
Gitee’s private warehouse function allows us to better protect the security and privacy of our code. In this article, we covered how to create a private repository, generate and add an SSH public key to Gitee, and push code to the private repository. Hope this article can help you!
The above is the detailed content of How to create a private repository on gitee and upload code to the repository. For more information, please follow other related articles on the PHP Chinese website!