我刚刚做了git init初始化我的文件夹作为git存储库,然后使用git remote add origin URL添加了一个远程存储库。现在我想删除这个git remote add origin,并添加一个新的仓库git remote add origin new- url。我该怎么做呢?
当前回答
你可以这样做,而不是删除和重新添加:
git remote set-url origin git://new.url.here
请参阅这个问题:如何更改远程Git存储库的URI (URL) ?
要删除远程使用这个:
git remote remove origin
其他回答
我没有足够的声誉来评论@user1615903的答案,所以添加这个作为答案: “git remote remove”不存在,应该用“rm”代替“remove”。 所以正确的做法是:
git remote rm origin
也许我迟到了 你可以使用git远程删除原点,它会做的工作。
Well, This method and technique worked fine for me:
Inside the .git folder of your project directory, change these files:
1 -> configs file
-> open it up
-> change the ref URL to the remote one.
(You must also set your remote origin
branch the same as the local
branch here inside this file. e.g: remote: main, local: main
)
2 -> git fetch
3 -> .git
-> refs
-> heads && remotes folder
-> make sure both in files, origins are the same inside both heads and
remotes folders. e.g: main or master
4 -> .git
-> refs
-> remotes
-> main
-> open it up:
Copy the content and paste it inside the main file of the heads
folder.
Finally:
Git fetch && git pull && git push
您可以进入。git文件夹,无需使用命令即可编辑配置文件。
另一种方法
取消本地git存储库(警告:这会删除历史记录)
rm -rf .git
然后;再次创建git仓库
git init
然后;重复远程回购连接
git remote add origin REPO_URL
警告:这将删除历史记录。
推荐文章
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 在Bash命令提示符上添加git分支
- 如何更改Git日志日期格式
- git pull -rebase和git pull -ff-only之间的区别