計算機科学のブログ

ほしい物リスト

Git - Undoing: Fixing Your Mistakes - reset command, mixed flag

Head First Git: A Learner’s Guide to Understanding Git from the Inside OutRaju Gandhi(著)、 O’Reilly Mediaの Chapter 4.(Undoing: Fixing Your Mistakes)、SHARPEN YOUR PENCIL(328/715)の解答を求めてみる。

入出力結果(Terminal, Zsh)

% git log --all --oneline --graph 
* ead1835 (HEAD -> master) A
% ls         
a.txt	b.txt
% git status   
On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	new file:   b.txt

% git commit -m 'B'
[master a9fb0c1] B
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 b.txt
% git status
On branch master
nothing to commit, working tree clean
% git reset --mixed HEAD~
% git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
	b.txt

nothing added to commit but untracked files present (use "git add" to track)
%