gitignore

xiaoxiao2021-02-27  153

.gitignore文件使用

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

语法

指定过滤某个文件

a.txt

指定过滤某种类型

*.zip *.rar

过滤某个目录

dir/

不过滤某个文件

!b.txt

用法

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

[lkc@lkcdeMacBook-Pro:] ~/Desktop/Code/gitSample $ git add .gitignore [lkc@lkcdeMacBook-Pro:] ~/Desktop/Code/gitSample $ git ci -m "ignore" [master acaf1c2] ignore 2 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 .idea/vcs.xml [lkc@lkcdeMacBook-Pro:] ~/Desktop/Code/gitSample $ git st On branch master nothing to commit, working tree clean [lkc@lkcdeMacBook-Pro:] ~/Desktop/Code/gitSample $ git add .idea/vcs.xml The following paths are ignored by one of your .gitignore files: .idea/vcs.xml Use -f if you really want to add them. [lkc@lkcdeMacBook-Pro:] ~/Desktop/Code/gitSample $
转载请注明原文地址: https://www.6miu.com/read-15766.html

最新回复(0)