git push -u origin <branch>
当您为bitbucket运行此命令时,它会为您提供输出,如
Counting objects:
remote:
remote: Create pull request for <branch>
remote: https://bitbucket.com/...
但是当我尝试将该输出存储在变量中并打印该变量时,它给出了这样的输出,
a=$(git push -q -u origin <branch>)
echo $a
Branch <branch> set up to track remote branch <branch> from origin.
我想存储上面的输出,或者我只想将拉取请求URL存储到变量中。
拉取请求URL是首选选项。 谢谢
答案 0 :(得分:2)
您可以将git
输出存储到文件中:
git push -u origin mybranch &> /tmp/git-push-origin-mybranch.txt
然后将内容存储到变量
中git_result=$(cat /tmp/git-push-origin-mybranch.txt)