现在,当我提交并想要推送和创建远程分支时,我做了:
app_folder (some_branch)> git push -u origin some_branch:some_branch
有没有办法编写 zsh alias ex: gpuwhich get the name of current branch and do that without my help?
这是一个非常基本的脚本。可能需要一些附加功能(和错误检查!),但它有效:
#!/bin/zsh
function branch() {
ref=$(git symbolic-ref HEAD)
echo "${ref#refs/heads/}"
}
# TODO: Let the user set the remote to push to?
git push -u origin ${branch}:${branch}
该branch()函数取自 Oh-My-ZSH git_prompt_info()- 它用于将电流git branch放入PROMPT.
这可能会作为一个zsh函数而不是别名很好地工作。