gitignore忽略文件

项目中已有 gitignore忽略文件

想要再修改 gitignore忽略文件,修改的内容是失效的,在填写忽略文件的过程中,我发现在Android Studio里面,.gitignore中已经标明忽略的文件目录下的文件,当我想git push的时候还会出现在push的目录中,原因是因为在Studio的git忽略目录中,新建的文件在git中会有缓存,如果某些文件已经被纳入了版本管理中,就算是在.gitignore中已经声明了忽略路径也是不起作用的,这时候我们就应该先把本地缓存删除,然后再进行git的push,这样就不会出现忽略的文件了。git清除本地缓存命令如下:


git rm -r --cached .
git add .
git commit -m 'update .gitignore'

运用

1.在用git时候,有时候需要忽略一些其他文件,不必要上传到git上去。
2.新建一个工程(项目),名字:gitignore 完毕。
3.利用命令,cd 工程目录下,回车。
4.然后 输入 touch .gitignore ,回车。
5.然后 输入 vi .gitignore ,回车。进入了 .gitignore文件里面了。
6.输入 i 进入编辑状态,
7.粘贴

# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.xcuserstate
*.DS_Store
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
Pods/
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build
# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode
iOSInjectionProject/

8.然后 输入 esc :wq! 回车 跳出vi
9.下面利用git 命令 把项目推送到远程仓库。
10.也就是把忽略文件加好了。(纯给自己看的,同学们若有不理解的,可加扣扣993056895)
11.dome 地址 这里

Android的忽略文件

参考文献:
Android开发中对.gitignore文件的配置
我用作者的那个,而不用网络流传的那个。

# Gradle directory
.gradle/
build/

# files for the dex VM
*.dex

#built application files
*.apk
*.ap_

# Java class files
*.class

# Local configuration file (sdk path, etc)
local.properties

.idea/workspace.xml
.idea/libraries
.idea/gradle.xml
.idea/misc.xml

# OSX files
.DS_Store

captures/
# generated files(studio中应该不需要)
bin/
gen/

# Windows thumbnail db
Thumbs.db

重新整理忽略文件

git rm -r --cached .  #清除缓存
git add . #重新trace file
git commit -m "update .gitignore" #提交和注释
git push origin master #可选,如果需要同步到remote上的话
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 目前做的项目大部分会通过git提交到代码服务器,有时在项目创建时就会添加.gitignore,有时会在后期添加,后...
    eiffel_加油阅读 4,490评论 0 0
  • 1.首先要在项目目录下添加或者创建一个.gitignore文件 注意:.gitignore文件是隐藏文件,如果你在...
    Anchoriter阅读 13,671评论 0 52
  • 1.首先为避免冲突需要先同步下远程仓库 $ git pull 2.在本地项目目录下删除缓存 $ git rm -...
    WananOH阅读 9,499评论 0 1
  • 场景: 原来已有.gitignore文件,但是项目开发过程中,突然心血来潮想把某些目录或文件加入忽略规则,按照忽略...
    木木公白阅读 3,868评论 2 2
  • 别看铜川是个四五线城市,同样也有一群斜杠青年。 近几年,人们把某类人称为“斜杠青年”,他们有如下的特征: 乐于帮助...
    primates阅读 3,418评论 0 1

友情链接更多精彩内容