Home> Development Tools> git> body text

How to use Git to upload code to gitee (steps)

PHPz
Release: 2023-04-10 14:57:42
Original
2622 people have browsed it

Git is a very practical version control tool that makes team collaboration more efficient. Gitee is a very popular code hosting platform in China. Next, let's take a look at how to use Git to upload code to gitee.

Step one: Create a gitee warehouse

First, we need to create a warehouse on gitee as the target location for uploading our code. On the gitee homepage, we click "New Warehouse", fill in the warehouse name and description, and determine the warehouse type, access permissions and other information.

Step 2: Create a Git repository locally

Then, in our local project directory, open the terminal and execute the following command:

git init
Copy after login

This will create the local project Create a Git repository in the directory.

Step 3: Connect the local project to the gitee repository

Next, we need to connect the local Git repository with the repository on gitee. In the gitee warehouse page, we can find an address similar to the following:

git@gitee.com:username/repo.git
Copy after login

We copy this address and execute the following command in the terminal:

git remote add origin git@gitee.com:username/repo.git
Copy after login

In this way, our local warehouse It is successfully connected to the gitee repository.

Step 4: Submit the local code to the local Git repository

In the local Git repository, we submit the code to Git through the following command:

git add . git commit -m "commit message"
Copy after login

Among them, " "Commit message" is the description of the code we submitted this time. This message should be concise and clearly describe the content of this submission.

Step 5: Push the local code to the gitee repository

After the local code is submitted to the local Git repository, we push it to the gitee repository. In the terminal, execute the following command:

git push origin master
Copy after login

Here, "master" refers to the name of the local branch we want to push. If you want to push to another branch, you can replace "master" with your branch name.

At this point, the code has been successfully uploaded to the gitee warehouse. After each code modification, you only need to follow the above steps and re-execute the code submission and push operations.

The above is the detailed content of How to use Git to upload code to gitee (steps). 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!