如何检查git中的上游URL?

发布于 2025-01-20 15:15:39 字数 1003 浏览 4 评论 0原文

如何确定我在新项目中为分支配置的上游 URL?

我像这样开始了新项目:

  1. 我克隆了一个 git 存储库,它是一个样板文件。
  2. 我在 github 中打开了一个新的仓库。
  3. 对本地克隆存储库进行了一些更改。
  4. 从上述步骤首次将新更改推送到新的 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:

  1. I cloned a git repo which is a boilerplate.
  2. I opened a new repo in github.
  3. Made some changes in the local cloned repo.
  4. 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 then git push --set-upstream origin main or the short git 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心凉怎暖 2025-01-27 15:15:39

我认为这只是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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文