LoginSignup
0

More than 3 years have passed since last update.

【Rails】ローカルのファイルをリモートリポジトリに上げない為のコマンド

Last updated at Posted at 2020-05-26

環境

Mac OS
Rails5.2.4

ローカルで使用しているファイルをリモートリポジトリ(例:Github等)に上げない様にする方法

terminal
touch .gitignore

.gitignoreという名前のファイルをtouchコマンドで作成。

作成場所は一番先頭のディレクトリー(Gemfileが置いてあるディレクトリ)にする。
このファイルに、リモートリポジトリには上げたくないファイルのパスを記載。
(画像を保存しているフォルダやパスワード等個人情報が記載されているファイルなどが対象となるかと
思います。)

すでにリモートリポジトリにpushしてしまったファイルをリモートリポジトリから削除・取り消したい場合

terminal
git rm -r --cached 【削除したいファイル名】

これで指定したファイルが、リモートから消えているはずです!

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
0