'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 .gits 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.
Solution 1:[1]
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.
Solution 2:[2]
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://<[email protected]/<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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Froziph |
Solution 2 | Community |