【Git】よく使うコマンド一覧

目次

 

ローカルリポジトリ

ローカルリポジトリとは、自分のマシン内にある作業ディレクトリのことです。

Gitの初期設定

// 初期化する
$ git init

add

ファイルの変更内容をステージ(インデックス)に追加するコマンド

// ファイルを追加
$ git add "ファイル"
// すべてのファイルを追加
$ git add .

 

commit

ファイルの変更内容をリポジトリに記録するコマンド

// 一つのファイルをコミット
$ git commit "ファイル"
// すべてのファイルをコミット
$ git commit .
// コメント付きのコミット
$ git commit -m "コメント"
// 直前のコミットを置き換える
$ git commit --amend
// 空白を削除
$ git commit strip

 

branch

// ブランチ一覧、作業中ブランチの確認
$ git branch
// 新しいブランチ作成
$ git branch "ブランチ"

 

checkout

// ブランチの切り替え
$ git checkout "ブランチ"

HEAD:作業中のコミットを指す

merge

$ git merge

rebase

$ git rebase

 

リモートリポジトリ

clone

$ git clone

pull

$ git pull

push

$ git push

remote

$git remote add origin master

 

引用サイト:
https://learngitbranching.js.org/