needhelp

Git メモ

一般的な Git コマンドのクイックリファレンス

セットアップと設定

コマンド説明
git initInitialize a new Git repository
git config --global user.name "Name"Set global username
git config --global user.email "email"Set global email
git config --listList all Git configuration
git clone <url>Clone a repository from URL

ブランチ

コマンド説明
git branchList local branches
git branch <name>Create a new branch
git checkout <branch>Switch to a branch
git checkout -b <name>Create and switch to a new branch
git merge <branch>Merge a branch into current
git branch -d <name>Delete a branch

コミット

コマンド説明
git add <file>Stage a file for commit
git add .Stage all changes
git commit -m "msg"Commit staged changes with message
git commit -am "msg"Add and commit all tracked changes
git commit --amendAmend the last commit

リモート

コマンド説明
git remote -vList remote repositories
git remote add <name> <url>Add a remote repository
git push <remote> <branch>Push to a remote branch
git push -u <remote> <branch>Push and set upstream
git pullPull changes from remote
git fetchFetch changes without merging

差分と比較

コマンド説明
git diffShow unstaged changes
git diff --stagedShow staged changes
git diff <branch>..<branch>Diff between two branches

ログと履歴

コマンド説明
git logView commit history
git log --onelineView compact commit history
git log --graphView commit history as graph

リセットと元に戻す

コマンド説明
git reset <file>Unstage a file
git reset --soft HEAD~1Undo last commit, keep changes staged
git reset --hard HEAD~1Undo last commit, discard changes
git revert <commit>Revert a commit by creating a new one

スタッシュ

コマンド説明
git stashStash working directory changes
git stash popApply and remove latest stash
git stash listList all stashes
git stash dropDiscard the latest stash

使い方

カテゴリ別に整理された一般的な Git コマンドを参照できます。検索フィルターを使って特定のコマンドを素早く見つけられます。各コマンドは構文と簡単な説明を表示します。

関連ツール