我有.gitignore文件与排除文件的名称。当我删除.git文件夹并做git init
,在git add *
后,我期望所有文件被添加,不会被.gitignore忽略。但是,.gitignore在git status
中显示为untracked文件,即使我在.gitignore中包含!.gitignore
,我也必须手动将其添加到git add .gitignore
。为什么“git add *”排除.gitignore?
1
A
回答
1
因为在你的命令*
实际上是从当前目录文件(和目录)的名称进行替换除了那些盯着W¯¯.
。如果你想也包括的.gitignore你应该叫:
git add * .gitignore
如果你想包括所有的点文件称:如果你正在使用的zsh
git add * .[!.]*
,您可以用更简单的模式:
git add * .*
相关问题
- 1. 排除的.gitignore
- 2. git add *和git add。有什么区别?
- 3. “git stash -A”如何排除.gitignore内容?
- 4. 为什么git remote add不起作用?
- 5. git add -A vs git add file
- 6. `git add .`和`git add -u`有什么区别?
- 7. git add有什么区别?和git add -A?
- 8. 为什么git在'git add'上发生'Assertion failed'错误。
- 9. 为什么.gitignore无效?
- 10. 什么时候应该使用rm,git rm,git rm --cached,git add
- 11. 为什么在git rebase应该这样做之后:git add?
- 12. 为什么我的commad“git add”。 comman不工作git bash?
- 13. “git add”的相反命令是什么?
- 14. .gitignore排除不工作
- 15. “git remote add”究竟干什么?
- 16. `git add -p`有什么选择?
- 17. git add * .c命令做什么?
- 18. 什么时候应该使用git add?
- 19. 要监视为什么git添加。慢?
- 20. 的.gitignore斜线排除行为
- 21. 为什么git忽略.gitgnore?
- 22. git add dirname/*
- 23. 从.gitignore中排除新创建的Makefile
- 24. 为什么git将这些文件重命名为add?
- 25. 什么是排除嵌套文件夹的gitignore模式?
- 26. 为什么文件删除没有通过“git add --all *”进行分段?
- 27. 为什么.gitignore在git状态下出现?
- 28. 为什么git不尊重windows上的.gitignore文件?
- 29. 为什么git add -A不会添加我所有的png文件?
- 30. 为什么`boot_transfer.php.cache`排除`E_USER_DEPRECATED`?
看来你的shell忽略glob扩展中的点文件。如果不知道您使用了哪个shell以及如何配置它,则无法多说。无论如何,这是一个简单的“如何使用我的操作系统”的问题,与编程无关。就我个人而言,我总是使用'git add .'并对整个业务进行旁观。 –
阅读此:http://unix.stackexchange.com/questions/70928/shell-wildcards-and-dot-files –