LoginSignup
796
689

More than 3 years have passed since last update.

gitの管理対象から特定のファイル、ディレクトリを削除する

Last updated at Posted at 2014-01-07

追記: 下記記載内容も含め、様々なTipsを記載: Git Tips - Qiita

gitの管理対象から特定のファイル、ディレクトリを削除する

.gitignore書き忘れて add & commit しちゃったとかよくありますよね。そんな人いないっすよね:-)
そんな時は git rm

ファイルも一緒に削除したいとき〜

$ git rm [削除したいファイル]

ディレクトリごと逝きたいとき〜

$ git rm -r [削除したいディレクトリ]

ファイルを残したいとき〜

--cachedオプションを付けることにより、ファイルを残したまま管理対象から外すことができます。

$ git rm --cached [削除したいファイル]

ファイルを残した場合は必ず.gitignoreに追記するように。

ちなみに~

.gitignore作るのは”gibo”を使うと便利です。

.gitignoreを作ってくれるgiboが便利すぎる - hnwの日記

796
689
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
796
689