git 使用 Bitbucket,如何将提交从一个分支提交到另一个分支?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31434513/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:11:52  来源:igfitidea点击:

Using Bitbucket, how do I get commits from one branch into another?

gitbranchbitbucket

提问by Roger_S

At my new job, where we use git with Bitbucket, we have a master branch, a new-features branch and a fix-these branch.

在我的新工作中,我们将 git 与 Bitbucket 一起使用,我们有一个主分支、一个新功能分支和一个修复这些分支。

I've been making all my changes to the fix-these branch. After committing them, I push them to origin/fix-these using SourceTree. So far, so good.

我一直在对修复这些分支进行所有更改。提交后,我使用 SourceTree 将它们推送到原点/修复这些。到现在为止还挺好。

In Bitbucket, how do I make the fix-these branch so that it includes the few commits that have been made recently to new-features? (And then I just "pull origin/fix-these" to make my local copy current, right?)

在 Bitbucket 中,如何修复这些分支,以便它包含最近对新功能所做的少数提交?(然后我只是“拉原点/修复这些”以使我的本地副本成为当前副本,对吗?)

采纳答案by Erik van Zijst

As Tim suggested, you'll want to merge new-features into fix-these.

正如 Tim 建议的那样,您需要将新功能合并到修复这些中。

You can do this on Bitbucket by navigating to the Compare page (see sidebar), selecting "fix-these" as destination, "new-features" as source and then hitting the Merge button in the top-right corner.

您可以通过导航到“比较”页面(参见侧栏),选择“修复这些”作为目标,选择“新功能”作为源,然后点击右上角的合并按钮,在 Bitbucket 上执行此操作。

回答by Ankit

Use git cherry pick. It lets you pick commit and add them over other branches.

使用 git 樱桃挑选。它允许您选择提交并将它们添加到其他分支上。

git cherry-pick <commit> 

Example:

例子:

git cherry-pick 123456

This will add the commit on the current branch.

这将在当前分支上添加提交。

回答by Karsten Sperling Opdal

You cant, you'll have to use git commands. Would have been nice with a web interface for it like pull requests.

你不能,你必须使用 git 命令。如果有一个像拉取请求这样的 Web 界面,那就太好了。