git
› Pro Git
› Atlassian Git Tutorial
› Pro Git 简体中文翻译
› GitX
stormslowly
V2EX  ›  git

git 小技巧一个 这次是认真的

  •  
  •   stormslowly · Jun 2, 2016 · 8477 views
    This topic created in 3811 days ago, the information mentioned may be changed or developed.

    假设现在在master分支

    $git checkout develop
    ....
    
    //技巧来了 
    
    $ git checkout -
    //回到了 master 分支  和 cd - 类似的作用
    
    Supplement 1  ·  Jun 2, 2016
    例子没有举好

    应该说当前分支是 branch1

    然后切换到了 branch2 完成了一部分工作

    要重新切换到 branch1 的话

    可以用 git checkout -
    40 replies  •  2016-06-03 23:00:44 +08:00
    expkzb
    expkzb
    Jun 2, 2016
    1
    get√
    old9
    old9
    Jun 2, 2016❤️1
    2
    搭车说一个自己常用的
    假设现在在 develop 分支, fetch 一下发现上游 origin/master 有更新,于是自己的 master 想 ff merge ,那么不用切换回 master ,直接在 develop 执行
    `git branch -f master origin/master`
    即可
    ango
    ango
    Jun 2, 2016
    3
    get √
    @old9 @stormslowly
    anyforever
    anyforever
    Jun 2, 2016
    4
    是不是从哪来就回哪去的意思
    GlobalNPC
    GlobalNPC
    Jun 2, 2016
    5
    用 alias
    stormslowly
    stormslowly
    OP
    Jun 2, 2016
    6
    @anyforever yes 就是和 `cd` 命令一样的意思
    youKnowDai
    youKnowDai
    Jun 2, 2016
    7
    @infun 用 alias 干啥
    wubt
    wubt
    Jun 2, 2016
    8
    get√
    ChiangDi
    ChiangDi
    Jun 2, 2016
    9
    如果你用 oh my zsh 的话直接敲 gcm
    dgkae
    dgkae
    Jun 2, 2016
    10
    酷
    dalang
    dalang
    Jun 2, 2016
    11
    呀 居然有这么多人不知道
    zixincao
    zixincao
    Jun 2, 2016
    12
    zsh :
    gco master
    hkongm
    hkongm
    Jun 2, 2016
    13
    gcm +1
    markx
    markx
    Jun 2, 2016
    14
    这个真不错。
    komiles
    komiles
    Jun 2, 2016
    15
    已 Get.
    LedChang
    LedChang
    Jun 2, 2016
    16
    按照 unix 哲学, option 作用应该大致是一样的吧
    O3YwA1ENkb7i35XJ
    O3YwA1ENkb7i35XJ
    Jun 2, 2016
    17
    欢迎来地球
    zhanglp888
    zhanglp888
    Jun 2, 2016
    18
    get√
    jason19659
    jason19659
    Jun 2, 2016
    19
    eclipse 用多了。。。 git 命令都忘的差不多了。。。
    loadingimg
    loadingimg
    Jun 2, 2016
    20
    新技能 get
    Ge4Los
    Ge4Los
    Jun 2, 2016
    21
    get 。。
    ibreaker
    ibreaker
    Jun 2, 2016
    22
    cd -
    williamx
    williamx
    Jun 2, 2016
    23
    get√
    yhxx
    yhxx
    Jun 2, 2016
    24
    Get
    fly2never
    fly2never
    Jun 2, 2016
    25
    这个和 cd - 是触类旁通的
    dexterlei
    dexterlei
    Jun 2, 2016
    26
    亲测有效,赞
    对我这种喜欢给 branch 起长名字,还爱跳来跳去的,简直是福音
    jzk
    jzk
    Jun 2, 2016❤️1
    27
    估计 lz 多半也不知道 @{u}是 upstream 的意思
    420K80U4tpmvKHjb
    420K80U4tpmvKHjb
    Jun 2, 2016
    28
    get
    stormslowly
    stormslowly
    OP
    Jun 2, 2016
    30
    @jzk @BOYPT 谢谢 学习到了
    Amayadream
    Amayadream
    Jun 2, 2016
    31
    idea 用多了,命令都忘得差不多了,只记得一个 git clone
    TankyWoo
    TankyWoo
    Jun 2, 2016
    32
    Good Tip
    KentY
    KentY
    Jun 2, 2016
    33
    @dexterlei git checkout Foo<tab> 你那不自动提示吗? 多长也不怕啊
    KentY
    KentY
    Jun 2, 2016
    34
    还有个和 LZ 同级别小技巧是那些常用的 checkout, commit, 各种 log 等, 用 alias co, ci, l ...
    shooter
    shooter
    Jun 2, 2016
    35
    HEAD~ HEAD^
    Kylinsun
    Kylinsun
    Jun 3, 2016
    36
    get√
    dexterlei
    dexterlei
    Jun 3, 2016
    37
    @KentY 我会习惯性地 tab 一下,但并没有什么用,是要设置什么吗?
    KentY
    KentY
    Jun 3, 2016
    38
    @dexterlei 不用设置啊, 自动提示啊, 要是你的 shell 配置好, 可以选择, 省很多事啊
    dexterlei
    dexterlei
    Jun 3, 2016
    39
    @KentY shell 是可以正常补全命令,但 git 后的不行,不知道为啥
    KentY
    KentY
    Jun 3, 2016❤️1
    40
    @dexterlei 你 google 一下 git completion, 有很多方案啊.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1460 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 91ms · UTC 05:51 · PVG 13:51 · LAX 21:51 · JFK 00:51
    ♥ Do have faith in what you're doing.