【问题标题】:git checkout without fetch from origingit checkout 不从原点获取
【发布时间】:2018-12-03 14:09:57
【问题描述】:

我在工作中使用 jira,我总是需要在 jira 中创建一个分支,在我的终端中我执行 2 个步骤

  1. git fetch origin feature/myticket-id
  2. git checkout origin feature/myticket-id

我怎样才能只使用单个命令,在不获取的情况下签出新分支?

【问题讨论】:

    标签: git github


    【解决方案1】:

    您需要先获取一些东西,然后才能在本地结帐。

    由于没有本地命令可以在一个操作中同时执行这两项操作,因此您需要一个别名,如“fetch and checkout a remote git branch in just one command”中所述

    [alias]
      fetch-checkout = !sh -c 'git fetch $1 $2 && git checkout $2' -
    

    用作:

    git fetch-checkout feature/myticket-id
    

    【讨论】:

    • 如何将其设置为我的别名?
    • 试过git config --global alias.fetch-checkout = !sh -c 'git fetch $1 $2 && git checkout $2' -我得到-bash: !sh: event not found的错误
    • 你可以在git config --edit打开的编辑器中简单地复制它
    猜你喜欢
    • 2012-09-16
    • 1970-01-01
    • 1970-01-01
    • 2019-04-03
    • 1970-01-01
    • 2020-03-21
    • 2018-11-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多