I know now you are stuck somewhere in your command line and Github repo. You probably want to remove the existing one and initialize a new one.
Okay, here is the solution.
Solution 1: Delete the .git directory
Git stores all files related to it in the .git
directory.
The first solution is to remove the files.
This directory might not be showing up in your folders since it is mostly hidden.
For Windows users:
- Navigate to your project folder in File Manager.
- On the top click on the Views tab.
- On the right, you will see a checkbox Hidden Items.
- Check the checkbox and a .git folder will be shown
For Mac-OS users:
There are two ways to view hidden files on Mac that is through Finder
or through the Macs Terminal
app.
View Hidden Files in Finder
- In
Finder
open your projects folder - Press
Command + Shift + .(a period)
- The
.git
directory will appear - Hit the same command to make the files invisible again
View Hidden Files in Macs Terminal App
- Open your
Terminal
under Launchpad > Other > Terminal. - Run the command:
defaults write com.apple.Finder AppleShowAllFiles true
- Press enter.
- Now run the command
killall Finder
- Press enter and now you are able to see your hidden files.
Note: After you have removed the
.git
hidden folder run:
- Run the command:
defaults write com.apple.Finder AppleShowAllFiles false
- Press enter
- Now run the command
killall Finder
- Press enter, this will hide the hidden files again
For Ubuntu users:
- Just type
Ctrl + H
and all the hidden files will be shown
Solution 2: Delete all .git folders by running a command
To remove all of the repositories associated with git run the following command:
Make sure you are the in the right directory before running this command.
rm -rf .git
Or
rm -rf .git*
-rf
(-r is for recursive and -f is to force the action)
To make sure the .git folder is removed run:
ls -lah
Solution 3: Delete all the .git folders using a different command
Run the following command to remove all .git
related folders including .gitignore
files and subfolders
find . -type f | grep -i "\.git" | xargs rm
Solution 4: Delete the entire project and restore it through backup
If the above solutions did not work for you might as well try to delete the project and then restore the backup.
- Delete all files except for
.git
- On the command line run:
git add . -A
- Next, run:
git commit -m “deleting the entire project”
- Lastly:
git push
Now you have to restore or create a backup of the project:
- Restore the backup or create a new project
git add . -A
git commit -m “recreating the project”
- Finally:
git push
Solution 5: Killing the TortoiseGit
- Open TortoiseGit > Settings
- Navigate to the Icon Overlays option
- Now change the Status Cache from Default to None
- Now delete the directory
- Set back the Status Cache from None to Default
- It should now be working.
If any of the solutions did not work for you please comment below and let me know.