代码之家  ›  专栏  ›  技术社区  ›  Bogdan Gusiev

简化一批git命令

git
  •  1
  • Bogdan Gusiev  · 技术社区  · 14 年前

    当我想将一个分支合并到另一个分支时,我会执行以下操作(在本例中,master to custom):

    git checkout master && git pull && git checkout custom && git merge master
    

    有人能建议如何简化这个过程吗?

    谢谢,波格丹。

    3 回复  |  直到 14 年前
        1
  •  3
  •   Ken Bloom    14 年前

    git checkout custom && git pull origin master

        2
  •  2
  •   Chris Johnsen    14 年前

    一般情况下不能简化。合并和拉(使用合并或钢筋网)都可能需要一个工作树来允许用户解决潜在的冲突。

    不过,您可以做一些简化的假设。

    如果你的本地 主人 从未发生过任何局部变化(即每次拉入本地 主人 将始终是一个快进更新;可能是因为您有一个本地 主人 是因为 Git克隆 自动为你做了一个),然后你可以忽略你的本地 主人 并重新配置本地 习俗 从你当地的上游 主人 使用。

    # copy "upstream" config from 'master' to 'custom'
    for o in remote merge rebase mergeoptions; do
        v="$(git config branch.master."$o")" && 
          git config branch.custom."$o" "$v"
    done
    

    然后,把上游 习俗 只要做 git checkout custom && git pull .

    或者,您可以直接在本地工作 主人 (移动你的 习俗 提交给 主人 具有 git checkout master && git reset --hard custom ,然后您可以放弃或删除 习俗 )

        3
  •  -1
  •   Jay    14 年前

    使用shell脚本