Gitリポジトリにファイルを保存するが、変更を追跡しない 質問する

Gitリポジトリにファイルを保存するが、変更を追跡しない 質問する

GitHub リポジトリにいくつかのファイルを含める必要がありますが、それらの変更を追跡する必要はありません。どうすればこれを実現できますか? 使用例の 1 つは、ログイン認証情報などの機密性の高いユーザー情報を含むファイルです。

たとえば、このフレームワークの新規インストールを新しいクライアントに展開し、次のファイルをダウンロードして (デフォルト値は CHANGEME です)、このクライアントに固有の変更 (データベース資格情報、電子メール アドレス情報、カスタム CSS) を加える必要があるとします。

// The production config files. I want the files but they need to be updated to specific client needs
application/config/production/config.php
application/config/production/database.php
application/config/production/tank_auth.php
// Index page, defines the environment (production|development)
/index.php
// All of the css/js cache (keep the folder but not the contents)
/assets/cache/*
// Production user based styling (color, fonts etc) needs to be updated specific to client needs
/assets/frontend/css/user/frontend-user.css

現在、私が走っている場合

git clone [email protected]:user123/myRepo.git httpdocs

そして、上記のファイルを編集すると、すべてうまくいきます。ホットフィックスまたはパッチをリリースして実行するまで、git pullすべての変更は上書きされます。

ベストアンサー1

git には、これを行うための別の解決策があります。まず、追跡したくないファイルを変更し、次のコマンドを使用します。

git update-index --assume-unchanged FILE_NAME

変更を再度追跡したい場合は、次のコマンドを使用します。

git update-index --no-assume-unchanged FILE_NAME

git-update-index ドキュメント

おすすめ記事