プログラミング勉強日記
2021年2月15日
基本的なgitの操作しかしらなかったので、今日知った便利なコマンドをまとめる。
Gitコマンド一覧
$ history
:コマンドの履歴を確認。
$ git log
:コミット履歴を確認。コミットをコミットメッセージの一覧の形で表示する。
$ git log -1
:最近のログを1件だけ出力する。
$ git log --since=2021-2-1
:2021年2月1日以降のログを出力する。
$ git log master
:ブランチ指定してログを出力する。
$ git log -p ファイルパス/ファイル名
:特定のファイルを指定してログを出力する。
$ git diff --name-only
:変更点を表示するときに、変更があったファイルのパスだけを表示。
grepとは
grepは、UNIXおよびUnixオペレーティングシステムにおけるコマンド。テキストファイル中から、正規表現に一致する行を検索して出力する。
$ git grep
の使い方
$ git grep
コマンドを使えば、Git管理下のファイルのみを対象としてgrepする。
特定の単語を含むか調べる
$ git grep "word"
大文字小文字を区別する
$ git grep -E "word"
大文字小文字を区別しない
$ git grep -i "word"