Customize Consent Preferences

We use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.

The cookies that are categorized as "Necessary" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... 

Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

No cookies to display.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

No cookies to display.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

No cookies to display.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

No cookies to display.

【時既に遅し】Gitでのファイル名を直で変更してしまった時の後処理方法。

Gitを使ってるプロジェクト内でファイル名を変更したい場合があると思います。
その際、git mvを使えば差分として認識されますがよくやりがちなエクスプローラーやエディタのプロジェクトツリーパネルから直で変更をしてしまう。

やりがちです。

ファイル名の変更は頻繁に行わないと思いますのでついついやってしまいますね。。
このようにgitコマンドを使用せず直で変更した場合、差分として認識されません。

数が少なかったり面倒でなければ、git resetやrevertで元に戻りますが
ぶっちゃけ個人レベルの開発でブランチも数個しか切っていない、
あくまでCI/CDを利用したく等バージョン管理としてあまり意識していないのであれば
頭を使いたくないと思います。

その時は下記をお試しください。

Gitでのファイル名を直で変更してしまった時の後処理。

ファイル名を直で変更した時は、差分認識されずステージングエリアに追加すらできません。以下を行うことで変更が反映されpushできます。

※きちんとバージョン管理する場合には、他の方法を行いましょう。
ファイル名変更後のファイルは新ファイルとして扱われ、コミット履歴を追えません。

キャッシュを削除する。

全体削除

git rm -r --cached .

ファイル指定

git rm -r --cached ファイル名

おわりに

次からは、git mv を使います。
Gitコマンドリファレンスもあるので
活用していきます。

Git コマンドリファレンス(日本語版)

 

 

コメント

スポンサーリンク
スポンサーリンク
タイトルとURLをコピーしました