gitignore

来源:互联网 发布:传奇物品数据库详解 编辑:程序博客网 时间:2024/06/13 06:38

.gitignore文件使用

  • 在使用git的过程中,有可能有些本地配置的文件或者一些自己的密码文件之类的不希望上传到远程库中,这时我们就需要.gitnore文件来帮我们忽略掉这些文件了.
  • 语法

    1. 指定过滤某个文件

      a.txt
    2. 指定过滤某种类型

      *.zip*.rar
    3. 过滤某个目录

      dir/
    4. 不过滤某个文件

      !b.txt
  • 用法

    先将.gitignore提交到远程仓库,然后删除掉远程仓库中包含过滤文件的缓冲,再次提交过滤的文件发现无法提交了

    [lkc@lkcdeMacBook-Pro:] ~/Desktop/Code/gitSample $ git add .gitignore[lkc@lkcdeMacBook-Pro:] ~/Desktop/Code/gitSample $ git ci -m "ignore"[master acaf1c2] ignore2 files changed, 1 insertion(+), 7 deletions(-)delete mode 100644 .idea/vcs.xml[lkc@lkcdeMacBook-Pro:] ~/Desktop/Code/gitSample $ git stOn branch masternothing to commit, working tree clean[lkc@lkcdeMacBook-Pro:] ~/Desktop/Code/gitSample $ git add .idea/vcs.xmlThe following paths are ignored by one of your .gitignore files:.idea/vcs.xmlUse -f if you really want to add them.[lkc@lkcdeMacBook-Pro:] ~/Desktop/Code/gitSample $
原创粉丝点击