When using GitLab, creating a new branch and submitting code are very basic and necessary operations. The specific steps are described below.
First you need to create a new branch locally. You can use the following command:
git checkout -b 新分支名
This command will create a new branch and switch the current branch to the new branch.
After the new branch is created, you need to push the new branch to GitLab. You can use the following command:
git push --set-upstream origin 新分支名
This command pushes the new branch to GitLab and sets it as the default branch. If you need to push an existing local branch, you can use the following command:
git push origin 本地分支名:远程分支名
where "local branch name" is the existing local branch name, and "remote branch name" is the name of the remote branch that needs to be created.
After you create a new branch locally and push it to GitLab, you need to submit the code on the new branch. You can use the following command:
git add . git commit -m "提交信息"
This command will add all files in the current workspace to the staging area and submit changes to the new branch.
At this time, you need to push the locally submitted code to GitLab. You can use the following command:
git push
This command will push the local code to GitLab. Modifications are pushed to the current branch on GitLab.
The above are the specific steps to create a new branch and submit the code. It should be noted that when pushing the branch or code to GitLab, you need to bind the user to the project first, that is, use The following commands:
git config --global user.name "用户名" git config --global user.email "电子邮件地址"
These commands bind a user and email address to a GitLab account so that commits can be recorded.
The above is the detailed content of How to create a new branch and submit code in gitlab. For more information, please follow other related articles on the PHP Chinese website!