Cannot push, pull or merge git. “Working copy has

2019-01-22 10:32发布

I have recently set up a git repository on bitbucket, and have added an old project onto it. I have committed and pushed a change as a test, but now I face this problem.

Each time I try to Pull, Push, or Merge I get this error message:

The working copy "" has uncommitted changes.

"The working copy 'Project_Name' has uncommitted changes".

And I have committed this change several times:

The file seems to be named: User Interface State


EDIT: I did 'git status' and got the following:

# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
#
# 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:   Crunch.xcodeproj/project.xcworkspace/xcuserdata/Neil.xcuserdatad/UserInterfaceState.xcuserstate
#
no changes added to commit (use "git add" and/or "git commit -a")

Help would be greatly appreciated, SirKaydian

5条回答
地球回转人心会变
2楼-- · 2019-01-22 10:38

I'm unfamiliar with the .xcuserstate file, but it sounds like a user-specific file. Generally user-specific files have no business in source control. They change frequently, generally are binary and thus difficult to diff, and aren't helpful to other users. Try closing down your IDE then running the commands or try adding this file name to your .gitignore file.

查看更多
干净又极端
3楼-- · 2019-01-22 10:44
git rm --cached *.xcuserstate *.xcuserdata

Run the above command. Then commit, then push.

See here: Xcode says "Uncommitted Changes" Whenever I try to git pull or push

You may need to run them separately :

git rm --cached *.xcuserstate
git rm --cached *.xcuserdata
查看更多
不美不萌又怎样
4楼-- · 2019-01-22 10:48

Okay, turns out I just had to make a comment

//THIS IS A TEST

And commit that. Now it works fine. This must have just been some strange bug.

Thanks for the help though, SirKaydian

查看更多
混吃等死
5楼-- · 2019-01-22 10:58

I solved this problem by:

git push <remote> localbranch --force.

Do not use the --force flag unless you’re absolutely sure you know what you’re doing.

查看更多
可以哭但决不认输i
6楼-- · 2019-01-22 10:59

Step 1:

git rm --cached ProjectName.xcodeproj/project.xcworkspace/xcuserdata/username.xcuserdatad/UserInterfaceState.xcuserstate

Step 2:

git commit -m "Removed file that shouldn't be tracked"
查看更多
登录 后发表回答