如何获得保存在bash脚本中的Git仓库variables

在运行postinstall到npm安装我的bash脚本我想获得一个特定的回购基地的Github远程URL。 但是,运行时提取的值是“git”,而不是我的git仓库的URL。 你将如何捕获从这个命令返回的url?

#!/bin/bash ... remoteBackup=git config --get remote.base.url ... 

var=$(command that produces output) not var=value command

后者运行commandvar在环境中设置为value

假设这就是你在脚本中的实际情况,而不是一个错字。 如果它是一个错字,并且让你回到git而不是git@bitbucket那么这听起来像你的configuration搞砸了。