首页 > 解决方案 > 如何发送合并请求?

问题描述

我在本地的 master 中完成了更改,我不想只是推送它们,而是我想创建一个新分支并让它包含所有想法,然后将其与 master 合并。

git status 显示所有更改的文件都已使用 git add 添加并使用 git commit -m "something" 提交但未推送,不确定这是否会影响后面的步骤。

我做了什么:

# Start a branch called new-feature
git checkout -b new-feature master
# Edit some files
git add <file>
git commit -m "something"
# Merge in the new-feature branch
git checkout master
git merge new-feature
git branch -d new-feature

但这没有用

标签: gitgitlabgit-merge

解决方案


您可以创建一个包含当前分支的当前状态的分支(在本例中为 master 分支)。为此,请运行以下行:

git checkout -b <new_branch_name>

运行这一行,您将位于新创建的分支中,其中包含您所做的本地提交。现在,您可以从这个新分支 ( ) 推送更改git push -u origin <new_branch_name>,然后向 master(或您想要的任何分支)打开一个 Pull Request。

要打开拉取请求,您可以访问存储库页面(例如,https://github.com/<your_user>/<your_repo>)并按下按钮new pull request。然后您只需选择来源和命运,添加一条消息并创建它。


推荐阅读