如何检查git中的上游URL?
如何确定我在新项目中为分支配置的上游 URL?
我像这样开始了新项目:
- 我克隆了一个 git 存储库,它是一个样板文件。
- 我在 github 中打开了一个新的仓库。
- 对本地克隆存储库进行了一些更改。
- 从上述步骤首次将新更改推送到新的 github 存储库。我使用命令
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
Is there a git command to find out the upper url of the新仓库中的新分支? (https://github.com/...../react-UI.git
)。
对于未来的项目,我可能会再次使用 github 存储库中的样板文件,我应该遵循相同的说明吗? (上面的步骤 1-4)
请注意,在两个存储库中我都使用“main
”分支。
How can I determine the upstream url I configured for my branch in my new project?
I started the new project like this:
- I cloned a git repo which is a boilerplate.
- I opened a new repo in github.
- Made some changes in the local cloned repo.
- Pushed the newly changes for the first time to the new github repo from the step above. I used the command
git remote add origin https://github.com/..../react-UI.git
thengit push --set-upstream origin main
or the shortgit push -u origin main
to configure the upstream url.
Now if I use the command git remote show origin
it shows me the url of the repo I cloned from.
However, when I navigate in the project directory to ./git/
and use cat ./config
It displays:
[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
Is there a git command to find out the upstream url of the new branch in the new repo? (https://github.com/...../react-UI.git
).
For future projects where I might use the boilerplate again from my github repo, should I follow the same instructions? (steps 1-4 above)
Please note that in both repos I use the "main
" branch.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这只是
git config-get branch.main.remote
您所做步骤1-4的方式似乎有效,但是我通常执行步骤1-4的方式是删除.git文件夹并创建一个新的存储库。除非您需要保留历史记录,否则这种情况有效,但是无论如何,历史记录仍将在样板式存储库中。
I think it is just
git config --get branch.main.remote
The way you did steps 1-4 seems to have worked, but the way I usually do steps 1-4 would be to delete the .git folder and create a new repo. That works unless you need to keep history, but the history would still be in the boilerplate repo anyways.