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

后端 未结 5 1442
一个人的身影
一个人的身影 2020-12-14 12:50

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.

相关标签:
5条回答
  • 2020-12-14 13:10
    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
    
    0 讨论(0)
  • 2020-12-14 13:16

    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

    0 讨论(0)
  • 2020-12-14 13:19

    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.

    0 讨论(0)
  • 2020-12-14 13:20

    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"
    
    0 讨论(0)
  • 2020-12-14 13:24

    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.

    0 讨论(0)
提交回复
热议问题