如何确定我在新项目中为分支配置的上游 URL?
我像这样开始了新项目:
git remote add origin https://github.com/..../react-UI.git
然后 git push --set-upstream origin main
或短 git push -u origin main
来配置上游 url。现在,如果我使用命令
git remote show origin
,它会显示我从中克隆的存储库的 URL。
但是,当我在项目目录中导航到
./git/
并使用 cat ./config
时,它会显示:
[remote "origin"]
url = https://github.com/....../react-boilerplate.git
fetch = +refs/heads/main:refs/remotes/origin/main
[branch "main"]
remote = https://github.com/...../react-UI.git
merge = refs/heads/main
是否有一个 git 命令可以找出新仓库中新分支的上游 url? (
https://github.com/...../react-UI.git
).
对于未来的项目,我可能会再次使用 github 存储库中的样板,我应该遵循相同的说明吗? (上述步骤 1-4)
请注意,在两个存储库中我都使用“
main
”分支。
我认为这只是
git config --get branch.main.remote
您执行步骤 1-4 的方式似乎有效,但我通常执行步骤 1-4 的方式是删除 .git 文件夹并创建一个新的存储库。除非您需要保留历史记录,否则这是有效的,但无论如何,历史记录仍然会在样板存储库中。
是否有 git 命令可以找出新仓库中新分支的上游 url?
git remote -v
产生输出:
origin git@<host>:<organization name>/<repo name> (fetch)
origin git@<host>:<organization name>/<repo name> (push)