【发布时间】:2019-03-25 14:27:49
【问题描述】:
【问题讨论】:
标签: git push git-push git-remote
【问题讨论】:
标签: git push git-push git-remote
这对我有用:
$ 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.
【讨论】:
取决于你想要远程的名称还是它的 URL,也可以
git push --dry-run --porcelain --verbose
在第一行中查看“To”之后的 URL 可能会。
【讨论】:
Enter passphrase for /home/ravi/.ssh/XXXX: git-receive-pack: permission denied: XXXX fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
fatal: No configured push destination.Either specify the URL from the command-line or configure a remote repository using...
--dry-run 仅在真正的推送有效时才有效。如果您希望能够获得远程推送,即使真正的推送失败,您也应该在问题中更清楚地说明这一点。
--verbose,仍然会打印URL。
答案并不像获取那么简单,因为有一个需要考虑的后备列表:
这些别名考虑了以上所有因素:
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
【讨论】: