Linux command
git-ignore 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Add to gitignore
git ignore [pattern]
Add multiple patterns
git ignore "*.log" "*.tmp"
Show current ignores
git ignore
Add to global gitignore
git ignore --global [pattern]
Add to private exclude file
git ignore --private [pattern]
说明
git ignore manages .gitignore entries, adding patterns to the repository's .gitignore or the global gitignore file. Without arguments, it displays the current .gitignore contents. Part of the git-extras suite, the command handles proper formatting and avoids duplicates. It creates .gitignore if the file does not exist.
参数
- -l, --local
- Add to local .gitignore (default).
- -g, --global
- Add to global gitignore.
- -p, --private
- Add to private exclude file (.git/info/exclude).
- --help
- Display help information.
FAQ
What is the git-ignore command used for?
git ignore manages .gitignore entries, adding patterns to the repository's .gitignore or the global gitignore file. Without arguments, it displays the current .gitignore contents. Part of the git-extras suite, the command handles proper formatting and avoids duplicates. It creates .gitignore if the file does not exist.
How do I run a basic git-ignore example?
Run `git ignore [pattern]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -l, --local do in git-ignore?
Add to local .gitignore (default).