ToolBoxy
💻

Git Cheat Sheet

git · reference · commands

セットアップ

git config --global user.name "Name"

Set your global username

コピー
git config --global user.email "email"

Set your global email

コピー
git config --global core.editor "code --wait"

Set VS Code as default editor

コピー
git config --list

List all configuration settings

コピー

初期化

git init

Initialize a new local repository

コピー
git clone <url>

Clone a remote repository

コピー
git clone <url> <dir>

Clone into a specific directory

コピー

ステージング & スナップショット

git status

Show working tree status

コピー
git add <file>

Stage a specific file

コピー
git add .

Stage all changes

コピー
git add -p

Interactively stage hunks

コピー
git diff

Show unstaged changes

コピー
git diff --staged

Show staged changes

コピー
git commit -m "message"

Commit staged changes

コピー
git commit -am "message"

Stage tracked files and commit

コピー
git commit --amend

Amend the last commit

コピー

ブランチ & マージ

git branch

List local branches

コピー
git branch <name>

Create a new branch

コピー
git checkout <branch>

Switch to a branch

コピー
git checkout -b <branch>

Create and switch to new branch

コピー
git switch <branch>

Switch branches (modern syntax)

コピー
git switch -c <branch>

Create and switch (modern)

コピー
git merge <branch>

Merge branch into current

コピー
git branch -d <branch>

Delete a branch

コピー
git branch -D <branch>

Force delete a branch

コピー

リモート

git remote -v

List remotes

コピー
git remote add origin <url>

Add a remote

コピー
git fetch

Fetch all remotes

コピー
git pull

Fetch and merge from remote

コピー
git pull --rebase

Fetch and rebase from remote

コピー
git push origin <branch>

Push branch to remote

コピー
git push -u origin <branch>

Push and set upstream

コピー
git push --force-with-lease

Safe force push

コピー

取り消し & リセット

git revert <commit>

Create revert commit

コピー
git reset HEAD <file>

Unstage a file

コピー
git reset --soft HEAD~1

Undo last commit, keep staged

コピー
git reset --hard HEAD~1

Undo last commit, discard changes

コピー
git checkout -- <file>

Discard file changes

コピー
git clean -fd

Remove untracked files/dirs

コピー

スタッシュ

git stash

Stash working directory changes

コピー
git stash list

List all stashes

コピー
git stash pop

Apply latest stash and remove

コピー
git stash apply stash@{n}

Apply specific stash

コピー
git stash drop stash@{n}

Delete a stash

コピー

ログ & 確認

git log --oneline

Compact commit history

コピー
git log --oneline --graph --all

Visual branch graph

コピー
git log --author="Name"

Filter commits by author

コピー
git show <commit>

Show commit details

コピー
git blame <file>

Show who changed each line

コピー
git diff <branch1>..<branch2>

Diff between branches

コピー

使い方

  1. 1

    コマンドや説明で検索します。

  2. 2

    セクションごとにgitコマンドを見ます。

  3. 3

    項目をクリックでコマンドをコピーします。

FAQ

このツールは無料ですか?

はい、登録もインストールも不要で、すぐに完全無料で使えます。

このツールはどんなツールですか?

必須Gitコマンドのクイックリファレンス。カテゴリ別整理、検索、クリックでコピーに対応。 登録もインストールも不要で、ページを開けばすぐに無料でお使いいただけます。