git のファイルシステムに存在しないファイルをコミットすることは可能ですか?
例:
git add "hello world" "hello.txt"
ファイル hello.txt に hello world を追加したいのですが、ファイルシステムに hello.txt を書きたくありません。
hello.txt は存在せず、git システム以外には存在させたくありません。(ファイルシステムにこのファイルを書きたくない)。これを行う方法はありますか?
よろしく
ブシエール
はい、このようなことができます。
# 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"
ファイルをローカルで作成し、git に追加し、コミットしてリポジトリにプッシュしないでください。次に、ローカル ファイルを削除して .gitignore に追加し、再びプルダウンされないようにします。
それはあなたの要件を満たしていない可能性があると思われますが、より多くのコンテキストが必要になる場合があります