use*_*320 126 windows git github
我在Windows上创建了一个本地GIT存储库.我们称之为AAA.我上传,提交并将内容推送到GitHub.git@github.com:username/AAA.git
我意识到我的名字弄错了.
在GitHub上,我将其重命名为 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
但我需要推送到git@github.com:username/BBB.git
现在.
我怎么能这样做?
hal*_*ons 265
git remote set-url origin <URL>
Run Code Online (Sandbox Code Playgroud)
jkp*_*jkp 124
在我看来(imho)调整这个最简单的方法是编辑存储库中的.git/config文件.查找您搞砸的条目,然后调整URL.
在我的机器上的回购我经常使用它看起来像这样:
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/*
Run Code Online (Sandbox Code Playgroud)
您看到注释掉的行是存储库的替代地址,我有时只需更改注释掉的行即可切换到该地址.
当你运行类似的东西git remote rm
或者git remote add
在这种情况下运行时,这个文件会在引擎盖下进行操作,因为它只是一个错字,你可以通过这种方式纠正它.
Abi*_*lah 59
另一种方法是:
git config remote.origin.url https://github.com/abc/abc.git
Run Code Online (Sandbox Code Playgroud)
要查看现有网址,请执行以下操作:
git config remote.origin.url
Run Code Online (Sandbox Code Playgroud)
Ste*_*lis 24
看看.git/config并进行所需的更改.
或者你可以使用
git remote rm [name of the url you sets on adding]
Run Code Online (Sandbox Code Playgroud)
和
git remote add [name] [URL]
Run Code Online (Sandbox Code Playgroud)
要不就
git remote set-url [URL]
Run Code Online (Sandbox Code Playgroud)
在你做错事之前,请仔细检查
git help remote
Run Code Online (Sandbox Code Playgroud)