skip to Main Content

I’m working on an XCode project, and I want to push my local changes.

However, my local and remote branch had diverged before I made local changes, so I understand that I have to do a ‘git pull and rebase local changes onto upstream changes’.
XCode instruction

This lets me resolve the conficts on XCode, except it cannot resolve files that I have deleted on purpose locally after my branch had diverged from origin/main. It has to pull first, but the local file it would pull remote changes onto doesn’t exist.
XCode screen

I have tried git pull --rebase origin main, then git rm for the deleted files and git add for other changes files in Terminal, but it doesn’t let me get past git rebase --continue because there are conflicts with my commits to XCode. I want to stay away from having to do it on Terminal because it crashed the last time.

What should I do? Any comments would be greatly appreciated.

2

Answers


  1. If you’ve deleted files locally and want to perform a git pull –rebase, you may encounter conflicts because git pull –rebase tries to replay your local commits on top of the remote changes. When local deletions conflict with remote changes (for example, if the remote repository still has those files), Git may struggle to reconcile these changes.

    Here’s how to handle this situation step-by-step:

    Step 1: Stash or Commit Any Uncommitted Changes

    git stash
    

    Step 2: Pull with Rebase and Handle File Deletions

    git pull --rebase origin <branch-name>
    

    Step 3: Resolve Conflicts for Deleted Files

    git checkout --theirs <path-to-deleted-file>
    

    Step 4: Apply Stashed Changes (if Any)

    git stash pop
    

    Step 5: Verify the Final State and Push Changes (if Necessary)

    git push origin <branch-name>
    
    Login or Signup to reply.
  2. It is helpful to close Xcode when doing a rebase to avoid conflicts of deleted files and do the rebasing in Terminal. Rebasing and merging in main can change the project file structure, and Xcode isn’t the most robust IDE.

    Once closed, in terminal you can chose to either delete or add the file that’s mentioned in the conflict by doing git add/git rm to add or remove the file and then continue the rebase. (git rebase --continue after adding or removing). It sounds like in your description you already got this down, so I wonder if keeping Xcode open is messing with this file and doing the steps with it closed could help.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search