LoginSignup
0
1

More than 1 year has passed since last update.

Git コマンド

Last updated at Posted at 2022-05-16

Git コマンド

  • 自分が使用するGitコマンドを備忘録として記載する

git clone

  • オプションなし
    • Gitリポジトリをクローンしてくる
git clone https://github.com/XXXXXX/hogehoge.git
  • --depth n オプション (Shallow clone)
    • Gitリポジトリから履歴数を指定してクローンしてくる
      (nは数。n=1にすると最新コミットのみ取得する)
git clone --depth n https://github.com/XXXXXX/hogehoge.git
  • --recursive オプション
    • Gitリポジトリから submodule も同時にクローンしてくる
git clone --recursive https://github.com/XXXXXX/hogehoge.git

git fetch

  • オプションなし
    • リモートリポジトリのコミット履歴を取得する。但しマージは行わない
git fetch
  • --prune オプション
    • リモートで削除されているリモートブランチを削除して反映
git fetch --prune

または

git fetch -p
  • --unshallow オプション
    • shallow clone (git clone --depth n)でクローンしてきたリポジトリの全ての履歴をコミットをフェッチすることができる
git fetch --unshallow 

git diff

  • オプションなし
    • ファイル変更差分を表示
git diff
  • --name-only
    • 変更差分のあるファイル名のみを表示
git diff --name-only

git log

  • オプションなし

    • コミット履歴を参照する(コミットコメント、および変更内容含む)
    git log
    
  • --oneline

    • コミット履歴を参照する(コミットコメントのみ表示)
    git log --oneline
    
    • コミット履歴を参照する(コミットコメントのみ + 直近N個のログを参照)
    git log --oneline -n N (Nは数字)
    

git submodule

  • 以下のコマンドでsubmodule を更新する

    git submodule update
    
  • 以下のコマンドでsubmodule をクローンしてくる

    git submodule update --init --recursive
    
0
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
0
1