Git推送到错误的存储库-需要将我的本地存储库重命名为我远程创建的存储库 [英] Git pushing to wrong repo - need to rename my local repo to the one I created remotely

查看:73
本文介绍了Git推送到错误的存储库-需要将我的本地存储库重命名为我远程创建的存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对git比较陌生,我认为自己已经陷入困境.为了测试一些功能;我在本地复制并粘贴到了一个repo目录中(我知道,这绝对是错误的选择.我没有想到).从那以后,我一直在努力并创建分支机构,这是我希望保持的进步.当然,当我尝试建立新的存储库并推送到它时...我的本地存储库想推送到旧的遥控器.

I'm relatively new to git and I think I've painted myself into a corner. In order to test some functionality; I copied and pasted over a repo directory locally (I know - absolute wrong thing to do. I wasn't thinking). I have since been working and creating branches - progress that I'd like to keep. Of course, when I tried to set up a new repo and push to it... my local repo wants to push to the old remote.

是否可以将现有的本地仓库(我复制的)的名称更改为新创建的,空的,远程的仓库的名称,以便当我进行推送时将其移至新的远程仓库?我不想覆盖文件,因为我需要保留分支.

Is there a way to change the name of the existing local repo (that I copied) to the name of the newly created, empty, remote one so that when I do a push, it will go to the new remote? I don't want to overwrite the file since I need to keep the branches.

我尝试过:

git remote add origin https://github.com/my-github-username/mygithubrepo.git

...认为我可以用新信息覆盖资源库网址-但这给了我错误:

...thinking that I could overwrite the repository url with the new info - but it gave me the error:

fatal: remote origin already exists.

...事后看来这是一件好事.我很高兴这没有用,因为我不想以任何方式修改原始远程仓库.就像我说的...我是git的新手.

...Which in hindsight is a good thing. I'm glad this didn't work, as I DO NOT want to modify the original remote repo in any way whatsoever. Like I said... I'm new to git.

任何建议或帮助将不胜感激.提前致谢!

Any advice or help would be greatly appreciated. Thanks in advance!

推荐答案

有没有办法将我复制的现有本地存储库的名称更改为新创建的本地存储库的名称...

Is there a way to change the name of the existing local repo (that I copied) to the name of the newly created...

您必须更改url:(将添加内容替换为set-url)

You have to change the url : (replace the add with set-url)

git remote set-url origin https://github.com/my-github-username/mygithubrepo.git

这篇关于Git推送到错误的存储库-需要将我的本地存储库重命名为我远程创建的存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆