【问题标题】:SourceTree finish feature with rebase - CLI equivalent具有 rebase 的 SourceTree 完成功能 - CLI 等效
【发布时间】:2018-12-23 11:34:55
【问题描述】:

一段时间以来,我一直在使用SourceTree 执行所有GitFlow 操作,包括关闭feature 分支。

现在我想更好地了解如何通过 git CLI 执行一些操作。

特别是,我不明白通过选择 rebase 选项来关闭功能的 CLI 等效项是什么,如下图所示。

我尝试过合并,但不能重现整个过程,什么是 CLI 命令来执行与 SourceTree 执行的操作相同的操作?

【问题讨论】:

    标签: git command-line-interface atlassian-sourcetree rebase git-flow


    【解决方案1】:

    可以在此处的原始博客文章文章中找到大多数 GitFlow 工具的原始命令行建议:

    https://nvie.com/posts/a-successful-git-branching-model/#incorporating-a-finished-feature-on-develop

    关闭一个特性分支包括以下步骤:

    $ git checkout develop
    Switched to branch 'develop'
    $ git merge --no-ff myfeature
    Updating ea1b82a..05e9557
    (Summary of changes)
    $ git branch -d myfeature
    Deleted branch myfeature (was 05e9557).
    $ git push origin develop
    

    SourceTree 中的复选框选项可能会执行一个额外步骤,即在合并之前将当前功能分支重新定位到开发分支的头部。如果您不熟悉git rebase 操作,我建议您先在这里阅读:

    https://git-scm.com/docs/git-rebase

    注意:虽然变基操作是一个完全正常的工作流程,但我几乎每天都使用它,如果您只是第一次使用它可能会导致问题,尤其是在存在冲突的情况下在您正在处理的功能分支和开发分支上的内容之间。我鼓励您单独尝试以下操作以适应正在发生的事情。

    因此,从上面查看功能工作流程的“正常”完成,您将执行以下操作:

    $ git checkout myfeature
    Switched to branch 'myfeature'
    $ git rebase develop
    Replay commits from myfeature branch onto the head of the current develop branch
    $ git checkout develop
    Switched to branch 'develop'
    $ git merge --no-ff myfeature
    Updating ea1b82a..05e9557
    (Summary of changes)
    $ git branch -d myfeature
    Deleted branch myfeature (was 05e9557).
    $ git push origin develop
    

    如果您在 rebase 操作之前和之后查看 git 存储库的历史记录,您应该希望能对正在发生的事情有所了解。如果您仍然不确定,您可能需要使用以下内容:

    http://git-school.github.io/visualizing-git

    这将帮助您可视化正在发生的 git 操作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多