Android Studio Git .gitignore vs Project>设置>版本控制>忽略的文件 [英] Android Studio Git .gitignore vs Project > Settings > Version Control > Ignored Files

查看:259
本文介绍了Android Studio Git .gitignore vs Project>设置>版本控制>忽略的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点困惑,我注意到,在Android Studio中设置我的第一个Git存储库后,所有要忽略的正确文件都会自动添加到设置>版本控制>忽略文件中的项目设置。



这看起来很神奇,我从来没有告诉过它该忽略什么。此外,在我的项目的任何目录中没有.gitignore文件,因为我习惯于创建。



这就是说,我无法让我的第二个项目自动添加被忽略的文件,真的,我只想使用简单的.gitignore方法。



有谁知道如何覆盖Android Studio的忽略文件列表,并简单地使用。而不是gitignore?我希望轻松将我的.gitignore复制到我制作的所有其他项目,但不会出现您可以复制设置>版本控制>忽略文件。



谢谢评论我如何才能使用.gitignore。

好的回答我自己的问题。要回到使用.gitignore,请执行以下操作:


  1. 转到设置>版本控制>忽略文件并删除所有被忽略的文件。点击应用。

  2. 仍然在设置>版本控制中将版本控制的类型从Git更改为无。点击Apply。

  3. 删除以前创建的项目的.git目录。
  4. 在项目的根目录下创建以下.gitignore文件:
    https://stackoverflow.com/a/21049338/459095

  5. VCS>启用版本控制...重新启用Git。

  6. 然后右键单击项目根目录并选择Git> Add以添加整个项目。 b

执行上述操作将利用.gitignore文件而不是设置>版本控制>忽略文件来提交正确的文件。


I am somewhat confused, I noticed that upon setting up my first Git repository in Android Studio all of the correct files to ignore were automatically added to the Project's Settings under Settings > Version Control > Ignored Files.

This appeared to be magic, I never told it what to ignore. Moreover, there is no .gitignore file in any directory of my project as I'm used to creating.

This being said, I can't get my second project to automatically add ignored files, and really, I just want to use the simple .gitignore method.

Does anyone know how to override Android Studio's ignored files list and simply use a .gitignore instead? I'd like the ease of copying my .gitignore to all other projects I make, it does not appear you can copy Settings > Version Control > Ignored Files.

Thank you for commenting on how I can just use .gitignore.

解决方案

Ok to answer my own question. To go back to using .gitignore, do the following:

  1. Go to Settings > Version Control > Ignored Files and remove all ignored files. Hit Apply.
  2. Still in Settings > Version Control change the type of version control from Git to none. Hit Apply.
  3. Delete the project's .git directory created previously.
  4. Create the following .gitignore file in the root directory of your project: https://stackoverflow.com/a/21049338/459095
  5. VCS > Enable Version Control... to Re-enable Git.
  6. Then right click on the project root and select Git > Add to add the entire project.

Doing the above will utilize the .gitignore file instead of Settings > Version Control > Ignored Files to commit the right files.

这篇关于Android Studio Git .gitignore vs Project>设置>版本控制>忽略的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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