030_options_of_reset_and_internal_structure_of_git_system_working_directory_index_repository
When you use "git reset",
there are several options that you can use
# ======================================================================
git reset --help
options: --soft, --mixed, --hard, --merge, --keep
Most used options: --soft, --mixed, --hard
# ======================================================================
working directory (= working tree, working copy)
directory where you're doing tasks
index (= staging area, cache)
place in which when you perform "add", data is stored
repository (= history, tree)
place in which version history, commits are stored
# ======================================================================
git reset --hard: reset 3 places 3군데 다 초기화됨
git reset --soft: reset history in repository
git reset --mixed: reset 2 places (repository, staging area)
# ======================================================================
# Initialize current directory
git init
vim f1.txt
init
git add f1.txt
git commit -m "1"
# ======================================================================
vim f1.txt
repository
git commit -am "2"
# ======================================================================
vim f1.txt
inex
git add f1.txt
git status
# ======================================================================
vim f1.txt
working copy
# ======================================================================
git reset --soft 65d9...
git log
git log -p
# ======================================================================
# To compare contents of working directory and contents of staging area
git diff
# ======================================================================
git reset --soft ORIG_HEAD
# ======================================================================
As you're doing tasks, if you don't like that tasks,
and if you want to go back to past code, run
git reset --hard
# ======================================================================
In most cases, you will use git reset --hard
But there can still be cases where --soft and --mixed are needed to use