Git - Undoing: Fixing Your Mistakes - subcommands, reset, restore 1
Head First Git: A Learner’s Guide to Understanding Git from the Inside Out、 Raju Gandhi(著)、 O’Reilly Mediaの Chapter 4.(Undoing: Fixing Your Mistakes)、EXERCISE(333/715)の解答を求めてみる。
入出力結果(Terminal, Zsh)
% git status
On branch boardgame-night
nothing to commit, working tree clean
% git branch
* boardgame-night
glamping-trip
main
% git reset --mixed HEAD~
Unstaged changes after reset:
M indoor-party.md
% git status
On branch boardgame-night
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: indoor-party.md
Untracked files:
(use "git add <file>..." to include in what will be committed)
boardgame-venues.md
no changes added to commit (use "git add" and/or "git commit -a")
% git log --oneline --all --graph
* 3e3e847 (HEAD -> boardgame-night) initial boardgame planning
| * cf5e718 (glamping-trip) initial outdoors plan
|/
* 8d704f8 (main) first cut at invitation card
* 6e16680 initial set of guests and gift registry
% rm boardgame-venues.md
% git restore indoor-party.md
% git status
On branch boardgame-night
nothing to commit, working tree clean
% git log --oneline --all --graph
* 3e3e847 (HEAD -> boardgame-night) initial boardgame planning
| * cf5e718 (glamping-trip) initial outdoors plan
|/
* 8d704f8 (main) first cut at invitation card
* 6e16680 initial set of guests and gift registry
%