7

I had apparently made a mistake in some code in the original git push from the command line. After about 5 retrys I need help. The code in the program is fixed but when I do

git init

It says

Reinitialized existing Git repository in 

What my question is. How do you wipe the memory of the git so that you can redo everything over again and upload it as if the code was there for the first time?

studentofmsu
  • 387
  • 1
  • 2
  • 9
  • Possible duplicate of [Make the current commit the only (initial) commit in a Git repository?](https://stackoverflow.com/questions/9683279/make-the-current-commit-the-only-initial-commit-in-a-git-repository) – phd Jun 13 '18 at 12:07

4 Answers4

20

This sovled the issue. If you had a previous mistake in git and want to delete it then do

rm -rf .git

Then do

git init

To start over

studentofmsu
  • 387
  • 1
  • 2
  • 9
  • this did it for me. I had run git init in the folder above and then again in the subfolder I actually wanted. this removed it and allowed it to work as I was expecting. you need to do the git init in the folder you want – Charles Harring Jan 05 '19 at 08:43
3
  1. open up git bash
  2. locate the folder
  3. type rm -rf .git
  4. then initialize the git like git init
Salahuddin Ahmed
  • 4,854
  • 4
  • 14
  • 35
0

You can fix the existing local commit by staging all the fixes and then running git commit --amend. Then, overwrite the remote branch by git push --force origin.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
0

If you ever want to reuse the old repository and its history, just rename the folder .git and then use the commands for a new start, either

git init

or

git clone

depending on the situation, if you have a remote repo your are starting from or if your local files are the starting point.

PythoNic
  • 303
  • 5
  • 13