As a popular domestic code hosting platform, gitee has brought a lot of convenience and help to many developers. However, for some novices, how to upload code to the gitee warehouse is a big problem. This article will detail how to upload your local code to the gitee repository.
Step one: Register a gitee account
If you don’t have a gitee account, you need to register one first. Open the gitee official website, click the registration button, follow the page prompts to fill in the relevant information, and perform email verification. After successful registration, you can log in to the gitee platform.
Step 2: Create a project
After logging in to gitee, you need to create a project first, which is the target repository for uploading code. Go to the gitee homepage, click "New Warehouse" in the upper left corner, fill in the project name, description and other information, select the type of warehouse you want to use (public or private), and click the "Create Warehouse" button.
Step 3: Select the warehouse address
On the project details page, you will see an HTTPS and SSH address. It should be noted that you need to use an HTTPS address to upload code, while the SSH address is mainly used to manage the warehouse and permission settings. Therefore, select the HTTPS address to copy.
Step 4: Install Git client
Git is a version management tool and the core tool for synchronizing local code with online warehouses. If you do not have the Git client installed, you need to download and install it first. You can download the relevant installation package from the Git official website.
Step 5: Clone the local code
On your computer, select a local code directory you want to upload to the warehouse, right-click the mouse and select "Git Bash Here". Enter the following command in the command line window to clone:
git clone https://gitee.com/your_username/your_repo
Among them, "your_username" represents your gitee account username, and "your_repo" corresponds to the name of the project just created.
Step 6: Add code files
Add the code files you want to upload to the warehouse in your local code directory. You can add the code file directly in the local directory, or you can copy the code file to the local directory after writing the code in the actual editor.
Step 7: Add the changes to the Git repository
After modifying the local directory, you need to add the changes to the Git repository. Open Git Bash and enter the following command:
git add .
This command will add all your files to the warehouse.
Step 8: Submit changes
After you have added all the files that need to be uploaded, you need to submit the changes to the local warehouse. Enter the following command in Git Bash:
git commit -m "your comment"
where "your comment" represents your description of this modification.
Step 9: Push the local code to the online repository
After you submit the local code, you need to push your local code to the online gitee repository. Enter the following command in Git Bash:
git push
Of course, if this is your first time to push, you need to enter the following command:
git push --set-upstream origin master
Among them, "master" is your master branch, enter After the command, you need to enter your gitee account password to verify your identity.
At this point, you have uploaded your local code to the gitee repository. In the gitee repository page, you can see that the file you just uploaded has been added to the code repository. If you have other modifications to make, just repeat steps 7 to 9, but please note that before pushing the code, you need to pull the code and then push it to ensure that the code you upload is the latest.
Summary
In this article we introduced how to upload local code to the gitee repository, which is one of the necessary skills in development work. Hope this article can be helpful to you.
The above is the detailed content of How to upload code to the warehouse in gitee. For more information, please follow other related articles on the PHP Chinese website!