LoginSignup
0
0

More than 3 years have passed since last update.

Git コマンド

Last updated at Posted at 2020-03-12

Gitコマンドについて

普段はEclipseを介して、操作しているのでコマンドを打つ機会がないので勉強ついでに記載する

環境
Windows10 Home
Git Bash
2.17.0

■git log

gitにコミットした履歴

git log

コミットしたファイル名のみを取得

git log -p --name-only

コミットしたファイル名から、特定の文字列が消えていることを確認

例はpythonファイルから、@をgrepする

git log -p --name-only | grep .py | xargs grep @

N個前まで取得する

git log -p -2

■git branch

ブランチの情報を取得

何も指定しない場合は、ローカルのブランチが表示される
リモートのブランチを表示する場合は、-r
両方取得したい場合は-aを付ける

git branch # ローカル
git branch -r # リモート
git branch -a # 両方

パターンに一致したブランチ名を取得

ワイルドカードは使用可能

git branch --list *feature*

ブランチの削除

git branch -d branchName

ブランチの作成

git branch branchName

ブランチをソート

=の後に、ソートキーを指定する

git branch --sort=authordate

■ブランチの切替

ブランチの切替

git checkout branchName

パターンに一致するブランチ名に切替

ブランチを切り替えるとき名前が長い場合やコピペするのが面倒な場合があるので

git branch --list *branchName* | xargs git checkout
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