如何从Android Studio项目中删除Git? [英] How do I remove Git from Android Studio project?

查看:1584
本文介绍了如何从Android Studio项目中删除Git?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Android Studio开发我的第一个项目,并且不能完全正确配置Git和GitHub.我想将项目从Git/Git中完全删除,然后重新开始.我怎样才能做到这一点?另外,我的项目文件夹中没有.git文件夹,那么我的git文件在本地存储在哪里,如何才能完全从Git和GitHub重新开始?

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?

我已经在设置"->版本控制"中将VCS设置为无",但是我不认为这会删除Git.该目录显示为未注册的根".我还想知道在此视图中显示几个目录是否正常?有时我有一个目录,此刻我有我的项目目录,并以未注册的根目录"app([我的应用程序目录])" ...

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] )"...

有一次,我设法将内容推送到GitHub上,但只推送了一些项目文件.我在初次提交后添加到项目中的其他项目显示为未版本控制,我添加了它们并尝试进行提交和推送,但没有.另外,每次我构建项目时,它们都会返回未版本化的状态.这就是为什么我想完全重新开始

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

推荐答案

AFAIK,您无法使用Android Studio删除它(没有用于从项目中删除Git的按钮).另外,.git是一个隐藏的文件夹,这意味着它(被隐藏).

AFAIK, you can't remove it using Android Studio (there isn't a button for removing Git from a project). In addition, .git is a hidden folder, meaning it is (well,) hidden.

Git也不以任何方式依赖于Android Studio.所有的Git历史记录都存储在.git文件夹中.

Git is also not dependent on Android Studio in any way. All of the Git history is stored in the .git folder.

(至少)有三个选项.

删除它的第一种方法非常简单.因此,当您进入项目根目录时,只需将/.git附加到路径中即可.

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

因此,如果您的项目根目录为D:/files/SomeProject,请附加Git文件夹,使实际路径变为D:/files/SomeProject/.git,然后删除其中的所有文件和文件夹.

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.

或者,您也可以使用命令提示符将其删除(请注意,这是假定您首先将cd插入根目录):

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:

Linux/Mac:

rm -rf .git

当然还有显示隐藏文件夹的选项,但这会在所有地方显示它们.至少对于Windows(10),搜索folder(或者,如果您的计算机不使用英语,则以适用的语言搜索),然后选择显示隐藏的文件和文件夹".向下滚动,直到找到Hidden files and folders并选择show.其他操作系统具有不同的方式,其中大多数可能会覆盖Internet上的某个位置(也可能是不同的Stack Exchange).

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).

无论采用哪种方式进行操作,现在只需执行git init,然后重新启动即可.以前的所有历史记录都将消失,活动树将成为左侧的树,因此请确保您位于右侧的分支上.删除.git文件夹时,如果不从远程重新拉动就无法恢复历史记录,并且这假定您拥有/使用了一个.

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.

请注意,如果您的项目已经上传到GitHub,则必须使用force标志(-f)进行推送.否则,它只会拒绝推送. 非常小心地使用-f标志;这会给其他在仓库上工作的人造成麻烦(尽管只有其他人才真正担心),并且它将覆盖存储在GitHub或您推送到的其他任何远程目录中的仓库的当前版本.通常是无法恢复的.

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.

这篇关于如何从Android Studio项目中删除Git?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆