Home > Development Tools > git > How to create a private repository on gitee and upload code to the repository

How to create a private repository on gitee and upload code to the repository

PHPz
Release: 2023-03-31 09:50:39
Original
5294 people have browsed it

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:

  1. Log in to Gitee and go to your profile page .
  2. Click the "New Warehouse" button.
  3. On the New Warehouse page, enter your warehouse name and description.
  4. Select the "Private" option in the drop-down menu.
  5. Click the "Create Warehouse" button.

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:

  1. Open a terminal and enter the following command:

    ssh-keygen

  2. In the prompt box Press the Enter key.
  3. Enter a name so you can identify the public key in the future. By default, this name is "id_rsa".
  4. Enter a password at the prompt (optional).
  5. Press the Enter key twice in a row.
  6. Generate SSH public key.

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:

  1. In your Gitee profile page, click the "SSH Public Keys" menu.
  2. Click the "Add SSH Public Key" button.
  3. Copy your public key into the text box.
  4. Click the "OK" button.

Step 5: Push the code to the private repository

To push the code to the private repository you created, follow these steps:

  1. 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.

  2. Go into your code directory and execute the following command:

    git add .

    git commit -m "This is a commit message"

  3. 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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template