LoginSignup
2

More than 3 years have passed since last update.

gitのローカルで行ったファイル削除をリモートに反映させる

Posted at

ローカルで不要なファイルを削除したが,すでにリモートへpushしてしまっていて,削除したことがうまく反映されないときの解決方法.

やること

git add -u # update option
git commit -m "deleted some files"
git push

コマンドの意味

git-addの公式ドキュメントを見ると,

-u
--update
Update the index just where it already has an entry matching . This removes as well as modifies index entries to match the working tree, but adds no new files.
If no <pathspec> is given when -u option is used, all tracked files in the entire working tree are updated (old versions of Git used to limit the update to the current directory and its subdirectories).__

とあり,太字にした箇所のように「インデックスのエントリをワーキングツリーに削除/同期する」とあるので,この機能を使ったことになるのだと思われ...
git rm [filename]でもできるそうだが,これは指定したファイルをgit管理下から外すという操作なので,複数ファイルを扱いたい場合には少し面倒.

参考

ほぼこのページの丸パクリです.
http://core.hatenablog.jp/entry/2013/08/09/134511

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
2