4ING 的航海日誌

你的理性與熱情,是你航行的靈魂的舵與帆 by Kahlil Gibran。把人生當成在海上航行,保持理性與熱情,這是我的航海日誌。

Git 常用命令

| Comments

將其他分支的某個檔案合併到目前分支

1
$git checkout other_branch target_file

顯示其他分支的檔案

1
$git show other_branch:path

比較兩個 commit 之間的差別

1
$git diff revision_1:file_1 revision_2:file_2

修改 commit 訊息

1
$git commit --amend

獲取遠端分支

1
2
$git fetch
$git checkout branch

刪除本地分支

1
$git branch -d branch_name

刪除遠端分支

1
$git push repository_name --delete branch_name

將檔案從 git 版本控制中移除(會導致其他 repository 將該檔案刪除)

1
$git rm --cached file_name

回復到上一個 commit 的狀態

1
$git reset --hard

回復某個檔案到上一個 commit 的狀態

1
$git checkout HEAD -- file_name

Comments