2
1

More than 3 years have passed since last update.

【Git】知らなかったGitコマンド・grepの使い方(備忘録)

Posted at

プログラミング勉強日記

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オペレーティングシステムにおけるコマンド。テキストファイル中から、正規表現に一致する行を検索して出力する。

Wikipedia grep

$ git grepの使い方

 $ git grepコマンドを使えば、Git管理下のファイルのみを対象としてgrepする。

特定の単語を含むか調べる
$ git grep "word"
大文字小文字を区別する
$ git grep -E "word"
大文字小文字を区別しない
$ git grep -i "word"

参考文献

Gitリポジトリ内をgrepする git grep はシンプルで超便利

2
1
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
2
1