我如何在Windows上更改远程/目标存储库URL? [英] How can I change the remote/target repository URL on Windows?
问题描述
我在Windows上创建了一个本地GIT存储库。我们称之为AAA。我上演,承诺并将内容推送到GitHub。 git@github.com:username / AAA.git
I created a local GIT repository on Windows. Let's call it AAA. I staged, committed, and pushed the contents to GitHub. git@github.com:username/AAA.git
我意识到我犯了一个名字错误。
I realized I made a mistake with the name.
在GitHub上,我将它重命名为 git@github.com:username / BBB.git
On GitHub, I renamed it to git@github.com:username/BBB.git
现在,在我的Windows机器上,我需要将 git@github.com:username / AAA.git
更改为 git@github.com:username / BBB.git
因为这些设置仍然试图推送到 git@github.com:username / AAA.git code>但我需要现在推送至
git@github.com:username / BBB.git
。
Now, on my Windows machine, I need to change git@github.com:username/AAA.git
to git@github.com:username/BBB.git
because the settings are still trying to "push" to git@github.com:username/AAA.git
but I need to push to git@github.com:username/BBB.git
now.
我怎么能这样做?
推荐答案
在我看来最简单的方法是修改。 git / config文件在你的仓库中。
The easiest way to tweak this in my opinion (imho) is to edit the .git/config file in your repository. Look for the entry you messed up and just tweak the URL.
在我的机器中,我经常使用它看起来像这样:
On my machine in a repo I regularly use it looks like this:
KidA% cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
autocflg = true
[remote "origin"]
url = ssh://localhost:8888/opt/local/var/git/project.git
#url = ssh://xxx.xxx.xxx.xxx:80/opt/local/var/git/project.git
fetch = +refs/heads/*:refs/remotes/origin/*
您看到注释的行是我有时候只是通过改变注释掉的那一行来切换。
The line you see commented out is an alternative address for the repository that I sometimes switch to simply by changing which line is commented out.
这是当你运行诸如 git remote rm
或 git remote add
,但在这种情况下,因为它只有一个错字,所以你可能对c直接用这种方法。
This is the file that is getting manipulated under-the-hood when you run something like git remote rm
or git remote add
but in this case since its only a typo you made it might make sense to correct it this way.
这篇关于我如何在Windows上更改远程/目标存储库URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!