Created
March 19, 2020 05:46
-
-
Save b2977053/dfde8901e347b34167f4b712292d9c59 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 建立資料夾 | |
mkdir git-reset-demo | |
cd git-reset-demo | |
# 建立版本庫 | |
git init | |
# 新增檔案 a.txt 並提交。 | |
echo 'a.txt first commit' > a.txt | |
git add . | |
git commit -m 'a.txt first commit' | |
# 新增檔案 b.txt 並提交。 | |
echo 'b.txt first commit' > b.txt | |
git add . | |
git commit -m 'b.txt first commit' | |
# 回到上一版本,重新 ADD、COMMIT | |
git reset 'HEAD^1' | |
git add . | |
git commit -m 'reCommit' | |
# 查看 LOG | |
git log --oneline | |
git reflog | |
# 用 --amend 追加 COMMIT (舊的 commit 物件不會變,他會另外新增 commit 物件) | |
git commit --amend | |
# 查看 LOG | |
git reflog |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment