How do I remove Git from Android Studio project?

AFAIK, you can't remove it using Android Studio (there isn't a button for removing Git from a project). (Upd.: now incorrect, but the rest of this answer is still correct and functional, because Git still works the way this answer relies on).

In addition, .git is a hidden folder, meaning it's, well, hidden. ls needs -a to show it, and most file explorers don't show the folder.

Git is also not dependent on Android Studio in any way. All of the Git history is stored in the .git folder, and is usable with or without Android Studio.


There are (at least) three options.

The first method to removing it is fairly simple. So when you go into your project root, simply append /.git to the path.

So if your project root is D:/files/SomeProject, append the Git folder so the actual path becomes D:/files/SomeProject/.git and delete all the files and folders in there.

Alternatively, you can also use command prompt to delete it (note that this assumes you cd into the root dir first):

Windows:

rd /s /q ".git"

Linux/Mac:

rm -rf .git

And there's of course the option to show hidden folders, but this shows them everywhere. At least for Windows (10), search for folder (alternatively in an applicable language if your computer doesn't use English) and select "Show hidden files and folders". Scroll down until you find Hidden files and folders and select show. Other operating systems have different ways, most of which are likely covered somewhere on the internet (possibly a different Stack Exchange as well).


No matter which way you do it, now you just do git init and you've restarted it. All previous history will be gone, and the active tree will be the one left, so make sure you're on the right branch. When you delete the .git folder, there's no way to recover the history without re-pulling from a remote, and this assumes you have/use one.

Note that if your project is already uploaded to GitHub, you have to use the force flag (-f) for the push. Otherwise it'll just reject the push. Use the -f flag extremely carefully; it will cause problems for anyone else working on the repo (though this is only really a concern if there are others), and it will overwrite the current version of the repo stored on GitHub, or in any other remote you push to, and this is usually unrecoverable.


From Android Studio Preferences,(My Android Studio version 3.6.1) Select Version Control->Select git Path-> Click ' - ' (minus button)->OK

Windows: File > Settings > Version Control > Select Project > '-' (Minus Button) >Apply > Ok enter image description here


What I have done to remove Android Studio project binding to GitHub is:

  1. I removed project on https://github.com first (you do not have to remove your project from GitHub though. Treat it as optional step)
  2. To remove GitHub binding to Android Studio project you need to go in Android Studio to File -> Settings -> Version Control. But DO NOT expand it, just mark it. Then, on the right hand side change, Git to None (red arrow on the picture below indicate this) enter image description here
  3. Finally remove hidden directory .git from your Project directory, this one which is specified in the picture below (I actually blurred mine :-) ).

Follwoing this three steps I were able to completely re-create fresh project on Github with the same Android Project.

What I do not like in the first answer (and I am not allowed to send comments yet) is that actually removes Github account, but do not remove binding between project in Android Studio and Github.