Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove Git from Android Studio project?

I'm developing my first project with Android Studio and can't quite get Git and GitHub configured properly. I'd like to completely remove my project from Git/Git from my project and start fresh. How can I do this? Also, there is no .git folder in my project folder, so where are my git files stored locally and how can I completely start over with Git and GitHub?

I've set VCS to 'None' in Settings -> Version Control, but I don't think this removes Git. The directory shows as "Unregistered roots". I was also wondering if it is normal to have several directories showing in this view? At times I've had and some directory, and at the moment I have my project directory and as Unregistered root "app ( [my app directory] )"...

At one point I managed to push stuff onto GitHub, but only some of my project files. Others, which I added to the project after the initial commit, showed up as unversioned, I added them and tried to commit and push, but couldn't. Also, they went back to unversioned every time I built my project. This is why I'd like to completely start over

like image 926
hubbabubba Avatar asked Jan 01 '18 16:01

hubbabubba


People also ask

Can we delete Git repository?

From this page, find the repository you want to delete, and click on the title. Then, locate the toolbar at the top and click the Settings tab. Scroll all the way to the bottom of the page until you see the Danger Zone section. Here, click Delete this repository.

How do I remove a Git repository folder?

Browse to the directory in the repository and branch that you want to delete. In the top-right corner, click "…", and then Delete directory. Review the list of files. Depending on your permissions and the branch protection rules, choose to either commit the change directly or propose the change using a pull request.


2 Answers

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

like image 90
Lins Louis Avatar answered Sep 21 '22 20:09

Lins Louis


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.

like image 35
Zoe stands with Ukraine Avatar answered Sep 21 '22 20:09

Zoe stands with Ukraine