Home > Article > Development Tools > How to push commits to different branches on Gitee
Gitee is a well-known Git code hosting platform in mainland China. It not only integrates Git code warehouse services, but also provides multiple functions such as project management tools and developer communities. If you host your code repository on Gitee, you may encounter situations where you need to save commits to different branches. This article will explain how to push commits to different branches on Gitee.
Before you start learning how to push commits to different branches, you need to first understand what a branch is. Branches are tools for parallel development in Git code repositories. Each branch represents a different version of the code repository. Therefore, if you need to commit different code to a different version, create a new branch first.
Creating a new branch on Gitee is easy. In your code repository page, select the "Code" tab and click "Create Branch." Enter the branch name in the pop-up dialog box and click "OK".
After you have created multiple branches, you need to select the branch to which you want to push commits. To switch branches, you need to enter the following command in the terminal or command line:
git checkout branch name
For example, if you need to switch to branch "dev", You need to enter the following command:
git checkout dev
On Gitee, switching branches is simple. In your code repository page, select the "Code" tab, and then select the branch you want to enter in the drop-down menu.
After you have switched to the correct branch, you can now save your code commits to that branch. To push a commit, you need to enter the following command in the command line or terminal:
git push origin branch name
where "branch name" is the branch you want to push name. For example, if you want to commit code to the branch "dev", you need to enter the following command:
git push origin dev
On Gitee, pushing commits is also Very simple. In your repository page, select the Code tab and select the branch you want to push to. Next, click the "Upload File" button in the upper right corner of the webpage. In the pop-up upload dialog box, add your file to the file list and select "Submit Changes".
Summary:
Saving code commits to different branches on Gitee is very simple. You just need to learn how to create new branches, switch branches, and push commits. These basic commands are the core of basic operations in Git code repository and are basic skills that every programmer should be proficient in. Whether you are just getting started with Git or you are an experienced programmer, these skills are very important.
The above is the detailed content of How to push commits to different branches on Gitee. For more information, please follow other related articles on the PHP Chinese website!