2011-07-27 22 views
19

何もしていないようだが、警告もエラーメッセージも出さなかった。何か案は?Gitリポジトリで `git add .git`を実行するとどうなりますか?

+7

実際には関連する質問です。私はちょうどそれをしたことを認めます。 '.gitignore'を追加したいのに' .git'でタブの補完が止まってしまったので、私はそれを打ちました。そして私は(あなたのように)「何を破壊したの?」と心配していました。 – Jarl

答えて

19

コメント:

/* 
* 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. 
*/ 

実験Iは、ファイル.gitを作成した場合に起こったかを見ると、それを追加しようとする: (Windows上で、私が作成することはできません。既に.gitフォルダがある場合は.gitというファイルがありますが、.gitというサブディレクトリも作成していましたが、--git-dirと私はこれまで使用していなかった。結局私は実験している。また、これはそうそう、.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 --git-dir="c:/test" --work-tree="c:/test" add c:/test 

すべてのメタファイルが追加されます。

これもまた.gitであり、私が見る限り、これは--git-dirで設定したgitメタデータフォルダでは無視されます。

+0

このコメントはどこのファイル/リビジョンでソース内にありましたか? –

+0

Nevermind、見つかりました - https://github.com/git/git/blob/fe9122a35213827348c521a16ffd0cf2652c4ac5/dir.c#L1277 –

+0

"the git metadata dir"とはどういう意味ですか? '--git-dir'で設定したディレクトリがあなたの作業ディレクトリですか? – HelloGoodbye

16

短い答え:何もありません。

長い答え:Gitのソースから

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$ 
関連する問題