Skip to content

Instantly share code, notes, and snippets.

@b2977053
Created March 19, 2020 06:33
Show Gist options
  • Save b2977053/d83388124241b6ccb3a8ef26836603ff to your computer and use it in GitHub Desktop.
Save b2977053/d83388124241b6ccb3a8ef26836603ff to your computer and use it in GitHub Desktop.
# 建立資料夾
mkdir git-revert-demo
cd git-revert-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'
# 查看 LOG
git log
# 將某個 commit 做相反動作
git revert <commit ID>
# 查看 LOG
git log
# 將某個 commit 做相反動作,但沒有 commit
$ git revert -n <commit ID>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment