git commit を取り消して変更を残す🔙 git reset --soft HEAD~1
git リポジトリのコピー git push --mirror
git 特定ブランチからの全ファイルのコピー git restore --source=[commit] .
git fetch して自分が古いと分かった場合
「Your branch is behind 'origin/feature_ulp' by 2 commits, and can be fast-forwarded.」
git reset --hard origin/main or git reset --hard @{u}git タグ管理 ... タグはcommitとは別に管理
git tag -a v1.0.0 -m 'テスト" git tag か git tag -l か git tag -n99git push --tags 新しい git では git push --follow-tagsgit fetch --tags; git tag -ngit remote で --push のみURLを変更する
git remote set-url --push origin [repository]
追跡されていないファイルを確認 git clean -n 削除 git clean -nf
追跡されていないディレクトリも含め確認 git clean -nd 削除 git clean -df
git checkout . はステージングを取り消すものではないのでステージングがある場合は明示的に取り消す必要がある
git reset --staged [file]
例えば以下のような問題が起こった
> git status
On branch feature_RTCLOG
Your branch is up to date with 'origin/feature_RTCLOG'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
deleted: .vscode/extensions.json
Untracked files:
(use "git add <file>..." to include in what will be committed)
.vscode/
> git checkout . <--😊すべてが戻そう
Updated 0 paths from the index <--😐あれ?!
> ls .\.vscode\
ディレクトリ: .vscode
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2026/09/24 7:50 63271 c_cpp_properties.json
-a---- 2026/09/24 7:50 322 extensions.json
-a---- 2026/09/24 7:50 1993 launch.json
> git checko
ut feature_RTCLOG2 <--😢まぁいいや、チェックアウトしよう
error: Your local changes to the following files would be overwritten by checkout:
.vscode/extensions.json
Please commit your changes or stash them before you switch branches.
Aborting
>😫なんで?!
前の処理で git rm --cached extensions.json 削除して戻したけど、git checkout .すれば全て戻ると思っていたのが勘違いこの場合は git reset --staging .vscode/extensions.json の後に git checkout . が必要