LoginSignup
0
0

More than 1 year has passed since last update.

【Git】.gitignoreって難しい Part2 - .gitignoreの作成未経験者が、ある程度の理解できるまで -

Last updated at Posted at 2022-06-16

.gitignoreの設定

昨日の記事に投稿させていただいた記事
https://qiita.com/misaki_soeda/items/c1dc6c6679f2ad561a8b

こちらで初期設定について書かさせていただきましたが、「最初に作り忘れていた時」があるかと思います。
既にリモートにあがっている、、データ量多いしどうしよう、、、

安心してください!大丈夫大丈夫~!

.gitignoreを最初に作り忘れていた時

■ .gitignore ファイルを生成

$ touch .gitignore

■ .gitignore ファイルに設定を記述する

.gitignore
# Nuxt dev/build outputs
.output
.nuxt
# Node dependencies
node_modules
# System files
*.log

ここまでは前回と同じですね。


次に、 .gitignore を追加したことをレポジトリにpushします。
$ git add .gitignore
$ git commit -m '.gitignoreを追加'
$ git push

最後に、 無視したいファイルをレポジトリから削除します。
$ git rm -r --cached .
$ git add .
$ git commit -am '.gitignoreに記述されたファイルを管理から削除する'
$ git push

完了!!

念の為コマンドの詳細

$ git rm -r --cached .
//ファイルを管理対象から除外する
$ git add .
ワークツリーで変更した内容をインデックスに追加
$ git commit -am '.gitignoreに記述されたファイルを管理から削除する'
一度addしたファイルに対して、addとcommitとを同時に行う

感想

Gitというか、コマンドってすごくない?!なんで今まで使わなかったんだろ?
できる事たーくさんある。コマンド全て使いこなしてみたい。笑

0
0
0

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
0