Git alias on current branch

后端 未结 4 527
没有蜡笔的小新
没有蜡笔的小新 2020-12-24 12:00

I\'d like to improve my current aliases, most of them work over a branch. Is there a way to refer to the current branch in a git alias so I don\'t need to pass it each time?

4条回答
  •  一生所求
    2020-12-24 12:50

    It's not 100% clear from your question which of these two aliases you require.

    This will push the currently checked out branch:

    git config alias.po !f() { export tmp_branch=`git branch | grep '* ' | tr -d '* '` && git push origin $tmp_branch; unset $tmp_branch; }; f
    

    This will push a given branch name (git po branchName):

    git config alias.po !f() { git push origin $1; }; f
    

提交回复
热议问题