How to fully delete a git repository created with

2020-01-22 13:49发布

I created a git repository with git init. I'd like to delete it entirely and init a new one.

标签: git git-init
23条回答
做个烂人
2楼-- · 2020-01-22 13:52

Where $GIT_DIR is the path to the folder to be searched (the git repo path), execute the following in terminal.

find $GIT_DIR -name *.git* -ok rm -Rf {} \;

This will recursively search for any directories or files containing ".git" in the file/directory name within the specified Git directory. This will include .git/ and .gitignore files and any other .git-like assets. The command is interactive and will ask before removing. To proceed with the deletion, simply enter y, then Enter.

查看更多
走好不送
3楼-- · 2020-01-22 13:53

Execute

rm -rf .git

in your repo folder

查看更多
祖国的老花朵
4楼-- · 2020-01-22 13:53

I tried:

rm -rf .git and also

Git keeps all of its files in the .git directory. Just remove that one and init again.

Neither worked for me. Here's what did:

  • Delete all files except for .git
  • git add . -A
  • git commit -m "deleted entire project"
  • git push

Then create / restore the project from backup:

  • Create new project files (or copy paste a backup)
  • git add . -A
  • git commit -m "recreated project"
  • git push
查看更多
聊天终结者
5楼-- · 2020-01-22 13:54

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 initial your 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 master

查看更多
该账号已被封号
6楼-- · 2020-01-22 13:56

Go to Specified Folder Where git init command executed.

Execute the below mentioned Command

rm -rf .git

Step No:1

enter image description here
Step No:2

enter image description here

查看更多
霸刀☆藐视天下
7楼-- · 2020-01-22 13:57

Alternative to killing TortoiseGit:

  • Open the TortoiseGit-Settings (right click to any folder, TortoiseGit → Settings)
  • Go to the Icon Overlays option.
  • Change the Status Cache from Default to None
  • Now you can delete the directory (either with Windows Explorer or rmdir /S /Q)
  • Set back the Status Cache from None to Default and you should be fine again...
查看更多
登录 后发表回答