1

Error

I got error

error: The following untracked working tree files would be overwritten by checkout:
MyProject/xcuserdata/shingo.nakanishi.xcuserdatad/UserInterfaceState.xcuserstate
Please move or remove them before you can switch branches.
Aborting

I try this

(The following untracked working tree files would be overwritten by checkout)

git rm --cached MyProject/xcuserdata/shingo.nakanishi.xcuserdatad/UserInterfaceState.xcuserstate

and

git clean -d -fx ""

git commit -a

git push

When 「UserInterfaceState.xcuserstate」file is not exist, this is work

But Xcode soon make UserInterfaceState.xcuserstate.

When I use Xcode, Xcode make UserInterfaceState.xcuserstate file.

So, Each checkout branch , I must do git clean -d -fx "" each Time.

My ~/.gitignore

this is my ~/.gitignore

.DS_Store
*UserInterfaceState.xcuserstate
*Breakpoints.xcbkptlist

How to ignore the file?

Community
  • 1
  • 1
shingo.nakanishi
  • 2,045
  • 2
  • 21
  • 55

3 Answers3

0

the first error means it is already in your repository (committed). you need to first remove it from the repository, then ignore it.

Dyno Fu
  • 8,753
  • 4
  • 39
  • 64
0

please read Git ignore file for Xcode projects

https://gist.github.com/3786883

Please search the SO before post questions.

For the change you have made. use git checkout -- <fileName> to discard changes.

Community
  • 1
  • 1
Kyle Fang
  • 1,139
  • 6
  • 14
0

Git doesn't ignore the files you already tracked. So just remove that file from git first

git rm -rf file 
git commit -m "remove"
git push origin #{branchname}

and after, you're .gitignore will ignore it :)

vladCovaliov
  • 4,333
  • 2
  • 43
  • 58