已删除的github存储库仍连接到终端中的本地文件

yhived7q  于 2023-02-07  发布在  Git
关注(0)|答案(1)|浏览(149)

我尝试将本地创建的项目推送到github,但出现了错误,因为我在github上创建了一个带有许可证的repo,而不是让它为空。当我尝试将当前本地保存推送到远程repo时,git bash会说没有什么可提交的,工作树清理,即使repo是空的保存为许可证和本地项目是充满文件.我删除了github上的repo,但是git bash在我启动项目时仍然会说(main),我通常在github上启动repo,然后是git clone,这是我第一次尝试反其道而行之。
我删除了原来的远程repo,这个项目应该是,并作出了一个新的是完全空的。错误:远程源已经存在。

HP@DESKTOP-A0NOAM6 MINGW64 ~/SideProjects/node-tutorial (main)
$ git branch -M main

HP@DESKTOP-A0NOAM6 MINGW64 ~/SideProjects/node-tutorial (main)
$ git push -u origin main
Enter passphrase for key '/c/Users/HP/.ssh/id_ed25519':
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 16 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 1.75 KiB | 1.75 MiB/s, done.
Total 5 (delta 0), reused 5 (delta 0), pack-reused 0
To github.com:manyLizards/node-tutorial.git
 * [new branch]      main -> main
branch 'main' set up to track 'origin/main'.

HP@DESKTOP-A0NOAM6 MINGW64 ~/SideProjects/node-tutorial (main)
$ git add -A

HP@DESKTOP-A0NOAM6 MINGW64 ~/SideProjects/node-tutorial (main)
$ git commit -m"initialized github repo"
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean

HP@DESKTOP-A0NOAM6 MINGW64 ~/SideProjects/node-tutorial (main)
$ git push origin --delete main
Enter passphrase for key '/c/Users/HP/.ssh/id_ed25519':
To github.com:manyLizards/node-tutorial.git
 ! [remote rejected] main (refusing to delete the current branch: refs/heads/main)
error: failed to push some refs to 'github.com:manyLizards/node-tutorial.git'

HP@DESKTOP-A0NOAM6 MINGW64 ~/SideProjects/node-tutorial (main)
$ git branch --delete --remotes origin/branch-name
error: remote-tracking branch 'origin/branch-name' not found.

HP@DESKTOP-A0NOAM6 MINGW64 ~/SideProjects/node-tutorial (main)
$ git branch --delete --remotes origin/main
Deleted remote-tracking branch origin/main (was dba3d90).

HP@DESKTOP-A0NOAM6 MINGW64 ~/SideProjects/node-tutorial (main)
$ git fetch origin --prune
Enter passphrase for key '/c/Users/HP/.ssh/id_ed25519':
From github.com:manyLizards/node-tutorial
 * [new branch]      main       -> origin/main`
2nc8po8w

2nc8po8w1#

我假设您不需要复制您的遥控器,因为您已经删除了它。

git remote remove origin

这将删除源,在您的例子中是main。此外,您可以更改.git\config中的URL以设置新的URL,而不删除远程repo。
参见hobbs's answer

相关问题