Git 常用命令
- Productivity
- 28 Jun, 2017
將其他分支的某個檔案合併到目前分支
$git checkout other_branch target_file
顯示其他分支的檔案
$git show other_branch:path
比較兩個 commit 之間的差別
$git diff revision_1:file_1 revision_2:file_2
修改 commit 訊息
$git commit --amend
獲取遠端分支
$git fetch
$git checkout branch
刪除本地分支
$git branch -d branch_name
刪除遠端分支
$git push repository_name --delete branch_name
將檔案從 git 版本控制中移除(會導致其他 repository 將該檔案刪除)
$git rm --cached file_name
回復到上一個 commit 的狀態
$git reset --hard
回復某個檔案到上一個 commit 的狀態
$git checkout HEAD -- file_name