0

I tried to push a project that I'd made locally to github and there was an error since I had created a repo on github with a license instead of leaving it empty. When I attempted to push the current local save to the remote repo, git bash would say there was nothing to commit, working tree clean even though the repo was empty save for the license and the local project was full of files. I deleted the repo on github, but git bash still says (main) when I pull up the project. I normally start the repo on github and then git clone, and this is my first time trying to go the opposite way.

I deleted the original remote repo that the project was supposed to be for, and made a new one that is completely empty. I tried git remote add origin git@github.com:manyLizards/node-tutorial.git; error: remote origin already exists.

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`
konsolebox
  • 72,135
  • 12
  • 99
  • 105

1 Answers1

0

I assume you don't need to make a copy of your remote since you already have deleted that. Run

git remote remove origin

which removes the origin, in your case main. Also, you can change the URLs in .git\config to set for new URLs without removing the remote repo.

see hobbs's answer

Talkhak1313
  • 301
  • 2
  • 11