在git pull
或git add .
的时候,总会出现一些的文件导致我们不能使用git add .
一次性添加所有的修改,或者不能使用git pull origin master
来合并远程修改,因为会报错
Your local changes to the following files would be overwritten by merge: xx.log
所以我们该怎么办呢?
解决办法:使用.gitignore文件
1. 创建.gitignore文件文件(前提:没有.gitignore文件)
- 可以在目录中右键选择git bash Here
- 使用
touch .gitignore
命令创建文件'
2.添加你想忽略的文件或文件夹
-
使用编辑器打开 .gitignore文件
image.png - 使用忽略规则来填写你想忽略的文件
忽略规则
target :忽略这个target目录
angular.json : 忽略这个angular.json文件
log/* : 忽略log下的所有文件
css/*.css : 忽略css目录下的.css文件
例如我想忽略主目录下WEB-INF/log/WebAgenda.log
文件
网友评论