使用Git重置或還原特定的文件到特定的修訂?我對一個文件進行了一些更改,該文件已作為文件組的一部分提交了幾次,但現在希望將對其的更改重置/還原回以前的版本。我做了一個git log連同一個git diff要找到我需要的修訂,但不知道如何將文件恢復到以前的狀態。
3 回答

慕桂英546537
TA貢獻1848條經驗 獲得超10個贊
git diff <commit hash> <filename>
git reset <commit hash> <filename>
--hard
git checkout <commit hash> git checkout -b <new branch name>
git checkout <my branch> git rebase master git checkout master git merge <my branch>

HUWWW
TA貢獻1874條經驗 獲得超12個贊
git checkout [commit-ref] -- [filename]
- 3 回答
- 0 關注
- 2181 瀏覽
添加回答
舉報
0/150
提交
取消