PaReeOhNos
PaReeOhNos

Reputation: 4428

Removed files on branch preventing git checkout

In my project I've got 3 branches : - master - dev - sync

I've done a bunch of work in sync, and somewhere along the way got fed up of committing xcode project files that I changed my gitignore to exclude them, stopped them being tracked, and removed them. This is fine, but now I want to merge my changes on sync back into dev.

Every time I try and checkout dev in order to merge, I get the error :

error: The following untracked working tree files would be overwritten by checkout:
ManagePlaces/ManagePlaces.xcodeproj/project.xcworkspace/xcuserdata/Aidy.xcuserdatad/UserInterfaceState.xcuserstate
ManagePlaces/ManagePlaces.xcodeproj/project.xcworkspace/xcuserdata/Aidy.xcuserdatad/xcdebugger/Expressions.xcexplist
ManagePlaces/ManagePlaces.xcodeproj/xcuserdata/Aidy.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist
ManagePlaces/ManagePlaces.xcodeproj/xcuserdata/Aidy.xcuserdatad/xcschemes/ManagePlaces.xcscheme
ManagePlaces/ManagePlaces.xcodeproj/xcuserdata/Aidy.xcuserdatad/xcschemes/xcschememanagement.plist

Please move or remove them before you can switch branches.

I understand why this is happening as the dev branch hasn't had these files removed and is still tracking them, but how can I get around this?

Upvotes: 0

Views: 812

Answers (2)

matt
matt

Reputation: 535586

Just add --force to your checkout command.

Upvotes: 1

qhduong
qhduong

Reputation: 26

I believe you can do this:

git checkout -- <file>

This should reset them to the last commit.

Upvotes: 0

Related Questions