2026-04-02 23:12:36 +08:00

35 lines
630 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: gitignore
createTime: 2022/04/28
tags:
- git
categories:
- 随记
---
## .gitignore 相关规则
```bash
# 忽略所有.a结尾的文件
*.a
# 将lib.a除外
!lib.a
# 忽略项目根目录下的abc
/abc
# 忽略template目录下的所有文件注意是左斜杠
template/
```
## git 处理.gitignore 完成不了的工作
```bash
# 添加被.gitignore忽略的文件
git add -f abc.
# 删除已经提交过&&包含在.gitignore中的文件
git rm --cached logs/xx.log
# 目录
git rm --cached -r logs
# 如果提示某个文件无法忽略,可以添加-f强制忽略
git rm -f --cached logs/xx.log
```