licrifandeMacBook-Pro:iOS-Client crifan$ git status On branch master Your branch is up-to-date with ‘origin/master’. Changes not staged for commit: (use "git add <file>…" to update what will be committed) (use "git checkout — <file>…" to discard changes in working directory) modified: JianDao/.DS_Store Untracked files: (use "git add <file>…" to include in what will be committed) JianDao/JianDao.xcodeproj/project.xcworkspace/xcuserdata/crifan.xcuserdatad/WorkspaceSettings.xcsettings JianDao/JianDao.xcodeproj/xcuserdata/crifan.xcuserdatad/xcdebugger/ no changes added to commit (use "git add" and/or "git commit -a") licrifandeMacBook-Pro:iOS-Client crifan$ git checkout v1.0 error: Your local changes to the following files would be overwritten by checkout: JianDao/.DS_Store Please, commit your changes or stash them before you can switch branches. Aborting licrifandeMacBook-Pro:iOS-Client crifan$ |
想要去掉一些无所谓的修改:
git checkout — benchmarks.rb
git reset HEAD CONTRIBUTING.md
licrifandeMacBook-Pro:iOS-Client crifan$ git checkout — JianDao/.DS_Store licrifandeMacBook-Pro:iOS-Client crifan$ git status On branch master Your branch is up-to-date with ‘origin/master’. Untracked files: (use "git add <file>…" to include in what will be committed) JianDao/JianDao.xcodeproj/project.xcworkspace/xcuserdata/crifan.xcuserdatad/WorkspaceSettings.xcsettings JianDao/JianDao.xcodeproj/xcuserdata/crifan.xcuserdatad/xcdebugger/ nothing added to commit but untracked files present (use "git add" to track) licrifandeMacBook-Pro:iOS-Client crifan$ |
然后就可以去切换了:
licrifandeMacBook-Pro:iOS-Client crifan$ git checkout v1.0 Switched to branch ‘v1.0’ Your branch is up-to-date with ‘origin/v1.0’. licrifandeMacBook-Pro:iOS-Client crifan$ |
[总结]
想要丢弃某个文件的修改:
git checkout — someTag |
转载请注明:在路上 » [已解决]git抛弃修改