Xcode Source Control - Push local changes stuck on Loading
Asked Answered
H

8

16

I keep getting this problem with Xcode source control. If I checkout a previous branch and then switch back to my latest branch, sometimes I can no longer push to my remote as it's stuck on loading.

enter image description here

I did find some workarounds which fix the issue like clone the project or use the terminal to push local changes but is there a better solution to fix it within Xcode.

I tried to reconnect my bit bucket account, clean build folder, update Xcode and restart everything but that solved nothing.

Hardie answered 9/9, 2019 at 2:38 Comment(0)
H
26

I managed to finally fix the issue. The issue seems to happen when checking out a previous build in Xcode. This would disconnect the remote which would cause it to be stuck on loading.

To fix it first, push any uncommitted work using the terminal e.g. git push origin head:master

Go to the Source Navigator in Xcode and check that the push you just committed is in the remote folder. For me, it's my remotes>origin>master

Then delete the master branch from Branches>master and then checkout Remotes>origin>master branch

The source control will now be able to push from Xcode. I hope that helps.

Hardie answered 15/3, 2020 at 22:20 Comment(1)
Cloning the project was a much easier solution.Garbe
T
4

It took a day to find out the easiest solution. You can re-install the Xcode but that's really time consuming and you can face the same problem again.

Just follow these steps to sort out the issue very fast:
1. Download and install Github Desktop.
2. Quit Xcode application and clear Xcode cache files.
3. Locate a local repository using Github desktop and click on "Fetch origin".
4. Make some changes, commit and push to your current working branch, it might be master branch.
5. Check latest commit message from your web browser, if you can see the latest commit then the problem has solved.
6. Just open the Xcode app, make some changes and try to commit and push. Great... Everything will work smoothly as it was before.

Topeka answered 22/1, 2020 at 8:43 Comment(1)
The issue I had was in Bitbucket but thanks for your helpHardie
W
2

This should be linked to cached credentials which are no longer available or current.

Check with git remote -v inside your repository if your URL is an HTTPS one or an SSH one ([email protected]:...)

If it is an HTTPS one, try, for testing, to switch to an SSH one, following the BitBucket documentation.

That issue was seen here and in this thread, which advocated a full re-installation of XCode, but I would check first the remote URL.

The OP STerrier confirms in the comments:

Re-installing Xcode was the only solution which worked

Watereddown answered 9/9, 2019 at 4:44 Comment(3)
Thanks, VonC, tried the above but to no avail. I probably will delete and reinstall Xcode when I have time.Hardie
Re-installing Xcode was the only solution which workedHardie
@Hardie OK. I have included your comment in the answer for more visibility.Watereddown
U
1

The solution is easy, but it's critical to identify what caused the problem. A detached head most likely caused it to happen when checking a previous commit and switching back.

To confirm it's a detached head, you can

  1. Install git. Config user and email
  2. You can see a hidden .git file in the project file directory. In the terminal, cd to this location
  3. Run git -status. This will tell you if there is a detached head and where it detached from
  4. Run git -log to check recent commits and the HEAD tag and press q to quit the log.

To fix the problem, you can

  1. Stage all changes and commit to the local repository
  2. Identify the HEAD following the above steps, and then Create A New Branch from The Commit where the HEAD tag is: Repositories -> Branches -> choose the "HEAD" commit and right click it -> select New Branch from "tag" Create new branch.
  3. Switch to this new branch. If you run git -status and git -log in the same directory, you can see the detached head is fixed, and the head is pointing to the new branch.
  4. Now, you can push the new branch to the remote repository as usual. The "loading..." text should be gone. You can merge and delete the new branch with another branch if you'd like.

Tip: Copy the whole project folder and save it elsewhere, just in case.

Unruh answered 26/12, 2023 at 1:2 Comment(0)
A
-1

this is an easy fix. take a copy of the working folder(just for caution). now check in the branch section in Xcode to see which is the current branch. hopefully, u won't see it has no current branch. next, see the name under the project, probably a mix of alphabets and numbers click on it and check if it has your latest commit. create a new branch from it and checkout. wolla!! now push it or merge it to the branch u wanted

Anthologize answered 2/5, 2022 at 11:54 Comment(0)
S
-1

I resolved the issue when I realized I was on a detached head. I merged my changes to the main branch and everything worked.

Sol answered 25/3, 2023 at 23:21 Comment(0)
E
-2

Download Github App for your laptop os.

then clone the project...

Expurgatory answered 21/10, 2020 at 3:59 Comment(0)
N
-4

I fixed the 'detached HEAD' and it worked.

Natation answered 16/12, 2020 at 19:32 Comment(3)
You should say how you fixed the detatched head, so that others can take advantage of your answer.Moina
Yes, can you please explain how you did that?Electroencephalograph
Google "how to fix a detached head" and you will find many suggestions. For example: https://mcmap.net/q/11960/-how-do-i-fix-a-git-detached-headNatation

© 2022 - 2024 — McMap. All rights reserved.