2

git のファイルシステムに存在しないファイルをコミットすることは可能ですか?

例:

git add "hello world" "hello.txt"

ファイル hello.txt に hello world を追加したいのですが、ファイルシステムに hello.txt を書きたくありません。

hello.txt は存在​​せず、git システム以外には存在させたくありません。(ファイルシステムにこのファイルを書きたくない)。これを行う方法はありますか?

よろしく

ブシエール

4

2 に答える 2

5

はい、このようなことができます。

# write new object to the object database, record its id
obj_id=$(echo hello world | git hash-object --stdin -w)

# add the new file to the index as 'hello.txt'
git update-index --add --cacheinfo 100644 $obj_id hello.txt

# Make a new commit adding the new file
git commit -m "Add new file"
于 2012-11-28T16:26:54.430 に答える
0

ファイルをローカルで作成し、git に追加し、コミットしてリポジトリにプッシュしないでください。次に、ローカル ファイルを削除して .gitignore に追加し、再びプルダウンされないようにします。

それはあなたの要件を満たしていない可能性があると思われますが、より多くのコンテキストが必要になる場合があります

于 2012-11-28T16:26:27.260 に答える