I created a git repository with git init. I'd like to delete it entirely and init a new one.
I created a git repository with git init. I'd like to delete it entirely and init a new one.
Git keeps all of its files in the .git directory. Just remove that one and init again.
If you can't find it, it's because it is hidden.
In Windows 7, you need to go to your folder, click on Organize on the top left, then click on Folder and search options, then click on the View tab and click on the Show hidden files, folders and drives radio button.
On a Mac OS:
Open a Terminal (via Spotlight: press CMD + SPACE, type terminal and press Enter) and run:
defaults write com.apple.finder AppleShowAllFiles 1 && killall Finder
Note: The keyboard shortcut to show hidden files in Finder is CMD + SHIFT + . so it is no longer necessary to modify the finder config this way
You could also type cd (the space is important), drag and drop your git repo folder from Finder to the terminal window, press return, then type rm -fr .git, then return again.
On Ubuntu, use shortcut Ctrl + H.
If you really want to remove all of the repository, leaving only the working directory then it should be as simple as this.
rm -rf .git
The usual provisos about rm -rf apply. Make sure you have an up to date backup and are absolutely sure that you're in the right place before running the command. etc., etc.
If you want to delete all .git folders in a project use the following command:
find . -type f | grep -i "\.git" | xargs rm
This will also delete all the .git folders and .gitignore files from all subfolders
after cloning the repo
cd /repo folder/
to go to the file directory then
ls -a
to see all files hidden and unhidden
.git .. .gitignore .etc
if you like you can check the repo origin
git remote -v
now delete .git which contains everything about git
rm -rf .git
after deleting, you would discover that there is no git linked check remote again
git remote -v
now you can init your repository with
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/Leonuch/flex.git
git push -u origin main
you can use :
git remote remove origin
to remove a linked repo then:
git remote add origin
to add new one
No worries, Agreed with the above answers:
But for Private project, please follow the steps for Gitlab:
You will be asked to type your project name
This action can lead to data loss. To prevent accidental actions we ask you to confirm your intention. Please type 'sample_project' to proceed or close this modal to cancel.
Now your project is deleted successfully.
In windows:
Now you can delete .git folder
Windows cmd prompt: (You could try the below command directly in windows cmd if you are not comfortable with grep, rm -rf, find, xargs etc., commands in git bash )
Delete .git recursively inside the project folder by the following command in cmd:
FOR /F "tokens=*" %G IN ('DIR /B /AD /S .git') DO RMDIR /S /Q "%G"
true,like mine was stored in USERS,so had to open USERS go to View on you upper left find Options,open it and edit folders'view options in view still to display hidden files/folders,all your folders will be displayed and you can deleted the repo manually,remember to hide the files/folders once done with the delete.