Git: New repository, error on trying to pushing existing repository from system

Viewed 185

all:

I'm trying to follow the instructions in the quick setup. Usually this works fine, but am experiencing problems this time around. Below are the instructions, to be executed from the repository I'm trying to push via Terminal:

git remote add origin https://github.com/abstractionAlpha/gradeCalculator.git
git branch -M master
git push -u origin master

However, when I try and execute the second command, I get the following error:

error: refname refs/heads/new_branch not found
fatal: Branch rename failed

As said in the title, I haven't touched anything in this repository. Tried adding new_branch manually but received fatal: Not a valid object name: 'new_branch'. Let me know if I can provide any other info.

1 Answers

Okay so I just spent some time with this problem as well. I think I have found a solution now - at least, it worked for me.

I had initialised a repo locally, but it was a folder that contained two folders, each with their own cargo, src., etc. I don't know if that contributed to the problem or anything.

I opened my main folder in explorer and deleted the .git folder (it may be invisible, you might have to select a view setting), and then I deleted the .git folders in each of the two folders contained in my main folder.

Then I opened VS Code and re did everything:

  • git init
  • git remote add origin
  • git add .
  • git commit -m "Initial commit"
  • git push -u origin master

I hope this works for anybody else with this problem.

Related