2012-10-15 84 views
1

我目前在(no branch)未提交更改。我想查看一個不同的分支並丟棄所有的更改。Git(沒有分支)與未提交的更改

當我做

git checkout <branch_name> 

我得到:

**error: Your local changes to the following files would be overwritten by checkout: 
     avar/libs/video_preprocessing_controller/video_preprocessing_controller.cpp 
     bbn/tracker/libs/init_and_cont_tracks/init_and_cont_tracks.cpp 
Please, commit your changes or stash them before you can switch branches. 
Aborting** 

我不想commit也不stash我的變化。我沒有第三種選擇嗎? (忽略他們/扔掉)

回答

6

使用git checkout -f [branch name]

或者,先扔掉你的本地修改,你可以用

git checkout . 
git checkout [branch name] 
+0

謝謝了! 'git checkout [branch_name]'報告我發佈的錯誤,但是'git checkout -f'似乎有訣竅。 –

+0

沒問題。請考慮接受這個答案,如果它幫助你:) – jonnystoten