git command to emit name of remote tracking branch

前端 未结 4 1002
无人共我
无人共我 2020-12-31 01:04

I\'d like a command that emits the name of the tracked branch for the branch I\'m on. Something like:

$ git checkout --track -b topic origin/master
Branch t         


        
4条回答
  •  离开以前
    2020-12-31 01:43

    git config --global alias.show-upstream '!sh -c '\''
    
        test -n "$1" || set -- HEAD
        set -- "$(git rev-parse --symbolic-full-name "$1")"
        git for-each-ref --format="%(upstream:short)" "$1"
    
    
    '\'' -'
    
    git show-upstream
    git show-upstream HEAD
    git show-upstream some/local/branch
    

提交回复
热议问题