Git コマンド - Himeyama/himeyama GitHub Wiki

Git を始める

バージョン確認

git --version

初期化

git init

ユーザー名の設定

git config user.name "NAME"

新規ファイル

リポジトリの状況を確認

git status

ステージング

data.txt をステージング

git add data.txt

変更があったファイルをすべてステージング

git add -A

# カレントディレクトリー以下に限定する場合は
# git add .

コミット

コミット

git commit -m 'MESSAGE'

リポジトリの状況を短く

git status --short

ステージングとコミットを一括で行う ただし、初回のみステージング (git add) が必要

git commit -a -m 'MESSAGE'

変更履歴を見る

git log

ヘルプ

git status について調べる

git status -help

実行可能なコマンドをすべて表示する

git help --all

ブランチ

hello-world ブランチの作成

git branch hello-world

ブランチ一覧を表示

git branch

hello-world ブランチへ切り替え

git checkout hello-world

hello-world ブランチの作成と切り替え

git checkout -b hello-world

リモートブランチの削除

git push --delete origin <ブランチ名>

空のブランチの作成

git checkout --orphan <ブランチ名>

リポジトリから秘密ファイルを削除

以下参照されたい。

https://docs.github.com/ja/[email protected]/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository

⚠️ **GitHub.com Fallback** ⚠️