美文网首页GitGitGit使用
Git使用指南1:.gitignore

Git使用指南1:.gitignore

作者: 林里icer | 来源:发表于2017-10-28 21:38 被阅读27次

写在前面

多人合作创建一个新项目的话记得创建.gitignore啊!不然的话一些乱七八糟的本地配置文件也被追踪了,别人pull下来还要处理这些文件真的是巨烦呀!

如果忘了添加

  • 这里以Andrlid为例
    下面是一个Android的.gitignore过滤文件
# OSX  
*.DS_Store  
  
# Gradle files  
build/  
.gradle/  
*/build/  
  
# IDEA  
*.iml  
.idea/  
.idea/.name  
.idea/encodings.xml  
.idea/inspectionProfiles/Project_Default.xml  
.idea/inspectionProfiles/profiles_settings.xml  
.idea/misc.xml  
.idea/modules.xml  
.idea/scopes/scope_settings.xml  
.idea/vcs.xml  
.idea/workspace.xml  
.idea/libraries  
  
  
# Built application files  
*.apk  
*.ap_  
  
  
# Files for the Dalvik VM  
*.dex  
  
  
# Java class files  
*.class  
  
  
# Generated files  
antLauncher/bin  
antLauncher/gen  
  
  
# Local configuration file (sdk path, etc)  
local.properties  
  
  
# Log Files  
*.log  
  
  
.settings  
  
.classpath  
  
bin  
  
coverage  
  
coverage.ec  
  
coverage.em  
  
gen  
  
javadoc  
  
junit-report.xml  
  
lint-results.*ml  
  
lint-results_files  
  
local.properties  
  
monkey.txt  
  
*~  
  
*.iws  
  
atlassian-ide-plugin.xml  
  
target  
  
out  
  
build.xml  
  
proguard-project.txt  

创建完上面的过滤文件后 需要执行以下方法才能生效:
改动过.gitignore文件之后,在repo的根目录下运行:

git rm -r --cached .
git add .

之后可以进行提交:

git commit -,m "fixed untracked files"

如果执行上面方法不能生效,并且在创建上面文件之前已经提交代码到版本库了,那么,这个时候可以尝试以下方法将想要过滤的相关文件,那么只能关掉开发工具,然后删除相关想要被过滤的文件。然后输入命令

git add -A
git commit -m "fixed untracked files"
git push origin master
git pull

相关文章

  • Git使用指南1:.gitignore

    写在前面 多人合作创建一个新项目的话记得创建.gitignore啊!不然的话一些乱七八糟的本地配置文件也被追踪了,...

  • 1 Git Tips

    [TOC]Git 常用命令 1. gitignore git .gitignore 文件只能够忽略 untrack...

  • 开发中Git问题小结

    1 Git的.gitignore配置 一般来说每个Git项目中都需要一个“.gitignore”文件,这个文件的作...

  • .gitignore

    全局.gitignore 文件1.需要一个.gitignore_global文件,文件链接:Android.git...

  • .gitignore的使用

    1:在目标工程目录下右键git bash,touch.gitignore 2:在.gitignore文件中添加想要...

  • .gitignore文件

    git rm与git rm --cached 1) gitignore文件 在git中如果想忽略掉某个文件,不让...

  • git 忽略文件夹或文件

    1.git config --global core.excludesfile '~/.gitignore' 2....

  • git-flow使用指南

    git-flow使用指南 1.简介 git-flow是基于Git Flow工作流模型的工具,了解Git Flow ...

  • git使用指南

    git使用指南 1.新建一个“本地仓库”$ git init 2.配置仓库》告诉git你是谁git config ...

  • Git小笔记+PostgreSql设置笔记。

    Git笔记 添加文件到 .gitignore 中命令:echo '.idea/*' >> .gitignore 从...

网友评论

    本文标题:Git使用指南1:.gitignore

    本文链接:https://www.haomeiwen.com/subject/caxepxtx.html