虽然它什么都不做,它没有给出任何警告或错误信息。有任何想法吗?当你在Git仓库中运行`git add .git`时会发生什么?
回答
评论:
/*
* Read a directory tree. We currently ignore anything but
* directories, regular files and symlinks. That's because git
* doesn't handle them at all yet. Maybe that will change some
* day.
*
* Also, we ignore the name ".git" (even if it is not a directory).
* That likely will not change.
*/
实验,看看发生了什么,如果我创建一个文件.git
,并尝试添加它: (在Windows上我不能创建文件.git
已经有一个.git
文件夹我也可以在子目录中的其他地方创建.git
但是想要尝试--git-dir
和--work-tree
我以前没有用过。毕竟我在做实验。这也让我证明我可以添加git的元数据文件夹,如下图所示)
git --git-dir="c:/test" init
touch blah
git --git-dir="c:/test" --work-tree="." add .
git --git-dir="c:/test" --work-tree="." status (shows blah added)
touch .git
git --git-dir="c:/test" --work-tree="." add .git (no output as usual)
git --git-dir="c:/test" --work-tree="." status (only blah shown)
所以呀,.git
- 无论是目录或文件,由混帐忽略。
如果我这样做如下:
git --git-dir="c:/test" --work-tree="c:/test" add c:/test
所有的元文件被添加。
所以再次,只有.git
被忽略,而不是git元数据文件夹(您通过--git-dir
设置),据我所知。
您在哪个文件/修订版本中找到了此评论? –
没关系,找到它 - https://github.com/git/git/blob/fe9122a35213827348c521a16ffd0cf2652c4ac5/dir.c#L1277 –
你是什么意思的“git元数据目录”?不是你用'--git-dir'设置你的工作目录的目录吗? – HelloGoodbye
简答:没什么。
龙答:从SVN源
laptop:Projects ctcherry$ mkdir test
laptop:Projects ctcherry$ cd test
laptop:test ctcherry$ git init .
Initialized empty Git repository in /Users/ctcherry/Projects/test/.git/
laptop:test ctcherry$ git add .git
laptop:test ctcherry$ git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)
laptop:test ctcherry$
- 1. 当用户在“git add”和“git commit”之前做“git push”会发生什么?
- 2. git环聊,当我运行'git add。'时
- 3. git submodule add fatal:不是Git仓库
- 4. git add *和git add。有什么区别?
- 5. 为什么git在'git add'上发生'Assertion failed'错误。
- 6. git在git之前运行脚本add
- 7. 运行克隆Git仓库
- 8. 在git仓库
- 9. 什么时候应该使用rm,git rm,git rm --cached,git add
- 10. 什么不包含在Git仓库中?
- 11. git push不是git仓库
- 12. git add -A vs git add file
- 13. 直接从git仓库中运行gem
- 14. 你如何组织你的git仓库?
- 15. 从ruby运行`git add -p`
- 16. 从git仓库
- 17. Maven Git仓库
- 18. git push会发生什么-u my_url master
- 19. 什么时候需要做“git pull”,在“git add,git commit”之前还是之后?
- 20. `git add .`和`git add -u`有什么区别?
- 21. git add有什么区别?和git add -A?
- 22. Git仓库和TFS仓库
- 23. GUI裸git仓库
- 24. 为什么Git提交-a(和git add,然后git commit)不会触发可执行文件pre-commit hook
- 25. Capistrano回滚 - GIT会发生什么?
- 26. 当GIT子模块“脱机”时会发生什么?
- 27. 当git合并失败时,其他文件会发生什么?
- 28. 当我用“--rebase”做git pull origin master时会发生什么
- 29. 什么时候应该使用git add?
- 30. Git仓库到Git仓库中的目录
其实是一个相关的问题;我承认我只是做了。我这样做是因为我想添加'.gitignore',但是在'.git'处停止了制表符,所以无意中我做到了。而且我(像你)担心的是“我摧毁了什么?”。 – Jarl