我如何发送合并请求?
How can i send a merge request?
我在本地的 master 中完成了更改,我不想只是推送它们,相反我想创建一个新分支并让它包含所有想法,然后将它与 master 合并。
git 状态显示所有更改的文件都已使用 git 添加并使用 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
但这没有用
您可以创建一个包含当前分支(在本例中为 master 分支)的当前状态的分支。为此,请执行 运行 这一行:
git checkout -b <new_branch_name>
运行 这行,您将在新创建的分支中,其中包含您所做的本地提交。现在,您可以从这个新分支 (git push -u origin <new_branch_name>
) 推送更改,然后向主分支(或您想要的任何分支)打开合并请求。
要打开合并请求,您可以访问存储库页面(例如,https://github.com/<your_user>/<your_repo>
)并按按钮 new pull request
。然后你只需 select 来源和命运,添加一条消息并创建它。
我在本地的 master 中完成了更改,我不想只是推送它们,相反我想创建一个新分支并让它包含所有想法,然后将它与 master 合并。
git 状态显示所有更改的文件都已使用 git 添加并使用 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
但这没有用
您可以创建一个包含当前分支(在本例中为 master 分支)的当前状态的分支。为此,请执行 运行 这一行:
git checkout -b <new_branch_name>
运行 这行,您将在新创建的分支中,其中包含您所做的本地提交。现在,您可以从这个新分支 (git push -u origin <new_branch_name>
) 推送更改,然后向主分支(或您想要的任何分支)打开合并请求。
要打开合并请求,您可以访问存储库页面(例如,https://github.com/<your_user>/<your_repo>
)并按按钮 new pull request
。然后你只需 select 来源和命运,添加一条消息并创建它。