Ubuntu下GitLab分支管理的常见操作
feature/login),选择基础分支(通常为main或master,作为新分支的代码起点),点击“Create branch”完成创建。cd命令导航到本地Git项目目录(如cd /home/user/projects/myproject)。git pull origin main(若基础分支为master则替换为master)。git branch命令创建分支(仅本地创建,未关联远程),例如:git branch feature/new-api。git checkout命令切换分支,例如:git checkout feature/new-api。git checkout -b命令,例如:git checkout -b feature/new-api(推荐,减少操作步骤)。git push/git pull):git push -u origin feature/new-api(-u参数表示建立追踪关系)。main),使用git branch -d命令(安全删除,若分支有未合并提交会提示):git branch -d feature/new-api;若强制删除(忽略未合并提交),使用git branch -D feature/new-api。git push命令,例如:git push origin --delete feature/new-api(GitLab Web界面也可删除:进入“Branches”页面,点击分支右侧“Delete branch”按钮)。feature/user-profile)并切换。git add .(将所有修改添加到暂存区);git commit -m "Add user profile page"(提交到本地仓库,提交信息需清晰描述修改内容)。git push origin feature/user-profile将本地分支推送到GitLab。feature/user-profile,即你的分支)和目标分支(main/master,要合并到的目标分支);