简体   繁体   中英

What will happen if I delete the .git folder after my work is done with git? Will I have to start new repository when working again on that directory?

You know, these .git s don't look fine in a PC when you work.So I have decided to delete it. But I'm afraid if it deletes my files/folders cloned/pulled from github under this repository.

Deleting the .git folder does not delete the other files in that folder which is part of the git repository.

However, the folder will no longer be under versioning control.

Since having a .git folder in tour sources is an issue when working on your files, you can clone your GitHub repo while setting the .git folder elsewhere (similar to " Can I store the .git folder outside the files I want tracked? "):

cd C:\path\to\parent\folder
git --git-dir=C:\path\to\myrepo.git --work-tree=myrepo clone https://<myaccount@githuub.com/<myaccount>/myrepo.git 
echo "gitdir: C:/path/to/myrepo.git" > myrepo\.git
cd myrepo
# start adding, committing, pushing

Of course, replace <myaccount> and " myrepo " with your GitHub account and your GitHub repo name.

But the idea is:

  • in your cloned repo path C:\\path\\to\\parent\\folder\\myrepo, there will be a .git file which will include the path of the actual .git repo
  • the .git repo folder will be located in another path outside of your local cloned repo: C:\\path\\to\\myrepo.git

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM