简体   繁体   中英

Git (no branch) with uncommitted changes

I am currently on (no branch) with uncommitted changes. I would like to check out a different branch and throw away all my changes.

When I do

git checkout <branch_name>

I get:

**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**

I don't want to commit nor stash my changes. Do I not have a third option? (ignore them/throw them away)

Use git checkout -f [branch name]

Alternatively, to throw away your local changes first, you can go with

git checkout .
git checkout [branch name]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM