実行前の状態
README.md を 1 回コミットした
この
ターミナル
git init -q -b main hello
cd hello
echo "# hello" > README.md
git add README.md
git commit -q -m "README を作る"
echo "start" >> README.md
echo "print('hi')" > app.py最小の例と結果
ターミナル
git statusOn branch main
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: README.md
Untracked files:
(use "git add <file>..." to include in what will be committed)
app.py
no changes added to commit (use "git add" and/or "git commit -a")On branch mainは、いま main ブランチに いるという 意味です。 Changes not staged for commitの下は、 変えたけれど、 まだ add していない ファイルです。 README.md が ここに出ます。 Untracked filesの下は、 Git が まだ 一度も 記録していない ファイルです。 新しく 作った app.py が ここに出ます。
成功の確認
出てきた-s を
ターミナル
git status -s M README.md
?? app.py左の 2 文字がM は?? は
構文と 主要オプション
| 書き方 | すること |
|---|---|
git status | いまの |
git status -s | 1 ファイルを 1 行の |
git status -sb | 短い形の |
git status <パス> | 指定した |
git status --ignored | .gitignore で |
失敗時の戻し方
git status は
よく
ターミナル
git statusfatal: not a git repository (or any of the parent directories): .gitcd でgit init は
よくある疑問
push が 弾かれた とき、 何を 見れば いいですか
先に git fetch で GitHub などのgit status をYour branch is behind とhave diverged と
どちらのbehind なら git pull でhave diverged のgit pull だけではgit pull --no-rebase で 2 つを
git status を 打つと、 何かが 変わりますか
ファイルの
日本語の ファイル名が "\343\201\202..." のような 数字の 列になります
Git はgit config --global core.quotePath false を
