答案 0 :(得分:3)
答案并不像获取那样简单,因为需要考虑一系列故障预置:
这些别名考虑了以上所有情况:
branch-name = "symbolic-ref --short HEAD" # https://stackoverflow.com/a/19585361/5353461
branch-remote-fetch = !"branch=$(git branch-name \"$1\") && git config branch.\"$branch\".remote || echo origin #"
branch-remote-push = !"branch=$(git branch-name \"$1\") && git config branch.\"$branch\".pushRemote || git config remote.pushDefault || git branch-remote-fetch #"
另外,URL:
branch-url-push = !"remote=$(git branch-remote-push \"$1\") && git remote get-url --push \"$remote\" #" # cognizant of pushInsteadOf
答案 1 :(得分:2)
还取决于您是否要使用遥控器的名称或URL
git push --dry-run --porcelain --verbose
,然后在第一行中的“ To”之后查看URL即可。
答案 2 :(得分:0)
这对我有用:
$ git remote get-url --push origin
来自文档 here:
**get-url**
Retrieves the URLs for a remote. Configurations for insteadOf and pushInsteadOf are expanded here. By default, only the first URL is listed.
With --push, push URLs are queried rather than fetch URLs.
With --all, all URLs for the remote will be listed.