If you’re like most developers, you use Git to track your code changes. But what if you want to remove Git version tracking from a folder? Here’s how to do it. First, create a new branch called “no-version” in your repository. Then, delete all of the files in the folder that have a .git extension. Finally, commit the changes to the no-version branch. Now, when you push your changes to GitHub, Git will not track them. This is useful if you want to work on a project without constantly worrying about which version of the code is currently being used. ..
If you’ve download a .zip from Github, or cloned a repository, it will be linked by default to the source repository. If you want to switch to your own repository, or remove version tracking entirely, you can do that easily.
Removing Git Entirely
Git stores all of its data, and most of its configuration, in a folder named .git. Removing this folder will completely remove Git version tracking from the directory, but it will also remove all Git version history. The folder will be like it never had Git installed.
If this is what you want, you can delete it. But, you may want to instead switch to your own repository, and keep the version history of the folder. This is useful if you want to download and fork a Github project (though Github does have tools to do that automatically).
The .git folder is hidden though, so the easiest way to delete it is through your terminal. If you’re connecting to a server over SSH, you’ll have to do this anyway. Navigate to the folder, and remove the .git folder:
If you’d prefer to delete it through your file browser, you’ll need to enable hidden files. You can do this on Windows by pressing Windows key and searching for “Show Hidden Files.”
Apple doesn’t make it as easy for MacOS. You’ll still need to use the terminal, and modify some config for Finder:
After that, you’ll be able to delete the .git folder from your file browser.
Switching To a New Repository (Remote)
If you’d like to keep the version history of your folder, you’ll want to leave the .git folder alone and instead remove and replace the existing remote. Git uses “remotes” to configure where it pulls updates from.
Note that removing a remote does not effect your repository—it simply disconnects it from Github, or wherever it’s hosted. You can then add a new remote, pointing to a new Github repository, and push your .git folder to your own repo.
You can list all the remotes alongside the URL they’re pointing to with remote -v:
You probably want to remove “origin,” the default remote. You can do that with remote -rm:
Then, you’ll want to fetch the new remote:
And push the whole folder:
If you made changes though, you will need to add and commit those changes before pushing.