支線(Branch)相關
所有支線列表
git branch
新增支線
git branch 你的新支線名稱
切換支線
git checkout 想切過去的支線
刪除支線
// 先切換到其他任一條線
git branch -d 想刪除的支線
合併支線
git merge
合併支線內容成一個 commit
git merge --squash 被合併的支線
提交(commit)相關
commit 後悔了
1. 若還沒 push 到 remote
git reset HEAD^ --hard
2. 已 push 到 remote ( 新增一個 commit 還原之前寫的 code )
// 取消一個 commit
git revert HEAD --no-edit
// 取消多個 commit
git revert HEAD~5 (取消五個)
同步相關
下載遠端資料並合併到本機
git pull // git pull = git fatch + git merge