Xcode stuck on wrong git branch - xcode

When trying to change branches I got an error saying my credentials were bad. Since then, Xcode shows the wrong branch. When I'm in command line it allows me to change branches, pull, commit etc...
When I try to change branches in Xcode, it says the repository is locked.
There's no lock file in .git and I can change from terminal (xcode doesn't change)
I've wiped derived data, restarted etc...
I completely deleted the project and recloned from GitHub Enterprise.
For a second it seemed to work...
but I tried to change branches and my old branches showed up and I got frozen again.
had to clone to the same directory however
Where is this state being cached so I can delete it and start fresh?
EDIT:
I've completely deleted Xcode, redownloaded the version I'm using (10.3), deleted these caches:
sudo rm -R ~/Library/Caches/com.apple.dt
sudo rm -R ~/Library/Preferences/com.apple.dt
as per this answer: https://stackoverflow.com/a/52541405/4522329
After I was setup, I reconfigured my Apple ID and GitHub Enterprise Account and recloned a second time.
Again things looked fine, until I tried to change branches...
Then my previous local branches popped up again showing me back on an entirely different branch and any attempt switch throws a repo locked error.
When I run 'git status' from command line, tons of duplicate files were pulled in from some cache and I'm shown on the branch I expect to be. I can do whatever I want from command line (still no lock file in .git), but it's not reflected in Xcode!!!
Also the launcher screen on Xcode is showing older, formerly deleted projects. There's some Xcode cache that's trying to recover from somewhere...

So this was weird. Still not sure the underlying reason.
I was able to resolve by wiping everything out again, cloning to a different location opening up in Xcode and cycling branches from within the IDE and then cycling through a few from command line and confirming the IDE was updating.
After that I moved the project to it's previous directory address. When I opened Xcode the recents list had two entries for the project in that location. I cleared both, then opened by directly clicking on my xcworkspace.
So far so good.

Related

Can`t see the file history in Gitlens (on a specific project)

I have a problem with Gitlens extension. Firstly, Gitlens or Git History extension is working fine on any other project except the this Laravel project. My problem is, can`t see the file history or line history in this project.
On the other hand, there is no problem in the git log (Git History Extension) as seen in screenshot;
But I can't compare any files with their any version (every commit seems like in the ss). I have no idea what the problem is about.
Lastly, I don't think the problem is about extension settings because other projects do not have this problem. Is there a any chance to fix this issue without resetting git history?
I am answering after 3 months, maybe it works for someone. As I mentioned in the title, surely there is no problem about extension settings for this specific project. The problem is just about git files. Maybe, I damaged some git files while moving the project on my desktop :)
So, there is no chance to fix this issue without resetting git history or starting fresh with git, if you`re having the same problem.
Do not play with git files, it`s no joke!
I've got a similar issue. My problem is in using symbolic links for folders.
I have this folder symlink for my repos.
C:\>dir
Directory of C:\
27.09.2018 21:07 <JUNCTION> repos [C:\Users\Qwerty\repos]
(GitLens v11)
The top editor is opened via C:\repos
The bottom editor via C:\Users\Qwerty\repos
You can see that some git features still work (yellow), but others don't.
However, this is very strange, because in my other repos, I have never observed such issues.
Also notice below that it is still possible to invoke the same action via a git lens popup and then it is possible to use the Prev Next Revision buttons.
Anyway, after more testing, I actually observe the same thing in my other repos. I assume that something must have changed between versions as I only observe these issues for last maybe 2-3 months. I even submitted a ticket that GitLens stopped working in v12.0.0 and later versions https://github.com/gitkraken/vscode-gitlens/issues/1979
The buttons completely disappeared and even the commit information
v11
v12
And Now actually, after having reopened my repo via original path and after updating GitLens back to v12.0.6 I see that it is working properly!
Bottom editor is opened via C:\repos symlink.

How to solve: Xcode shows files still as modified after commit

I am using SourceTree as a git client.
A while ago, I had a major problem with my project and my git, so I had to reactivate a copy of my workspace from an external source. For that purpose I had created a complete new repository. Commiting to that now.
Today I've noticed, that most of my files appear as "modified" in Xcode. Even after commit and push (with SourceTree).
Source Control shows my two branches, what is correct:
And the History shows perfectly all the commits:
My feeling tells me, that in the background the old repository information is still present and does this bug. How do I handle this? Help is very appreciated.
Edit:
git diff --ws-error-highlight=new,old Output
Close Xcode. If you can avoid it, don't reopen Xcode :-) If it's an absolute must, reopen Xcode. The M markers should be gone.
This worked for me:
Delete derived data folder(Steps: Click Xcode on top left -> Preferences -> Locations -> Click on the right arrow below Derived Data and that will you take you to the Derived Data folder in Finder. Delete it)
Quit Xcode (Don't just close the project)
Reopen Xcode
Check if the nature of the diff is related to eol (end of lines).
See "git diff - show me line ending changes?", like:
git diff --ws-error-highlight=new,old
If that is the case, try first:
git config --global core.autocrlf false
Then try again to clone your repo, and see if XCode still display those differences.
In your case, this is not about eol, but about an update done in your files.
Check for any .gitattributes file: is there a smudge directive in those files (which would explain an automatic process taking place on checkout)
See Keyword expansion for an example of smudge script.
Something seems to update JTAppleCalendar to its latest relase (6.0.1 from 7 days ago)
My feeling tells me, that in the background the old repository information is still present and does this bug.
Simply try, in command-line, to clone again that repo (in a brand new local path) and check if the issue persists in that new cloned repo.
to the JTAppleCalendar, I have changed from 6.0.0 to 6.0.1 manually. around 7 days ago. when the new xcode 8.0.1 arrived
In that case, all those files should be listed as modified: that is what Git does.

Xcode Server won't build because source control information is in an invalid format

I have XCode Server set up with XCode 6.4 and OSX Server 4.1.5. I had integrations running fine until I transferred my git repository to another bitbucket account. No big deal right? Wrong for me :(. After I transferred my repository, I changed my git remote, I changed the repository location in Preferences in Xcode on my dev computer as well as on my server. Regular git functions are working fine from the command line and from within XCode. Nothing seems wrong until I try to run an integration and then it gives me the following build service error:
Could not check out sources because the source control information is in an invalid format.
I tried deleting my bot and creating another one. I tried cloning my project straight from the new location into another folder in case something had gotten out of sync. I git reset hard to the remote branch just in case even though there was nothing different. I tried cleaning and restarting everything multiple times. I reset XCode Server too (sudo xcrun xcscontrol --reset) and am still getting the error making me think I really did somehow mess up my git repository as far as XCode is concerned, but I have no ideas about what XCode doesn't like about my source control information. Does anyone have any ideas for what I can do or try? I've been tearing my hair out for hours.

XCode Won't Commit To GIT

Been googling for a while with no luck.
I have been working on my app for a week and I'm trying to commit to git now, so I can start branching and try some new stuff. But I can't commit my changes. I get the following message:
"The working copy "APP NAME" failed to commit files.
fatal: Could not switch to '/Users/Leonne/Documents/iOS Projects/APP NAME/APP NAME/Resources': No such file or directory"
I have initialized the git repository. I don't understand what could be going on.
Before, I did create a "Resources" folder, but deleted it afterwards. I never committed with the existence of this "Resources" folder. I deleted the Resources folder because it was giving me troubles whenever I tried to compile my app. I'm working with XCode 4.4.
Any help will be appreciated.
Ok, I just experienced this problem today morning. I don't know if mine is THE perfect fix. My Mac crashed and I restarted, and I could commit again.
If my fix hold true with you as well, then it could be a bug with XCode.
Edited
It seem my error still exists and the following is my fix.
It seem Xcode GUI have some problem with using GIT properly. So i used the terminal to do this. I went to the working directory and then did a git status this will show you a list of files that were deleted/modified/added. You can manually add them all together using git add or just a straight git commit -a (not recommended on complex projects)
This solved the commit issues and when i went to Xcode, the error doesn't seem to exists anymore
Looks like I have the bad habit of solving my hour-long problems 5 minutes after I post about them on StackOverflow, haha.
My fix was rather easy. I navigated to the specified route and re created the Resources folder. I added the folder to my project via XCode's "add files" feature. Directly afterwards I deleted it from there, moving it to trash. Now I can compile and commit, thank goodness.

Unable to create snapshots with XCode

I am unable to take any more snapshots of a particular project of mine in XCode. If I try to create a snapshot, it says 'Creating snapshot ..' in the status bar and goes on forever. I then force quit the Xcode, relaunch and try creating a snapshot again. This time it straight away gives the error message '..remove file manually .. ...lock'. So I then remove the shown file using the rm command in terminal. And then I again try creating the snapshot and the same cycle continues.
How can I fix this issue?
I had been taking snapshots for this project for a long time and one day had to delete all the old snapshots as I suddenly realized that they are taking up 12+ GB! Even now if I try to create a snapshot for this project it reaches 3 GB in a few minutes and then I force-quit it.
(I am pretty certain this used to work perfectly until some time back and didn't take gigabytes in space.)
Since you tagged this question git, I suspect git is the cause of your problem. I have found Xcode snapshots do not work if the project is in a git repository. If you need to take a snapshot, a workaround is to move the .git folder out of your project temporarily, take the snapshot, and move the .git folder back.
I too had the same problem and this is how I fixed it:
I noticed in Xcode -> Organizer -> Repositories that my whole ~/username folder was showing up as a repository. I tried deleting it in Xcode but it kept returning. Previously, before I had installed Xcode 4, and using Xcode 3, I had installed GIT and cloned opdenkamp/xbmc to my home folder. Through a lack of knowledge on the use of GIT, I had made my whole folder a repository and every time I tried to make a snapshot of my project in Xcode it was making a snapshot of ~/username (or some other process) that was taking for ever and creating a multi GB file in ~/Library/Developer/Xcode/Snapshots/ . In fact I would "force quit" Xcode to stop the process.
So I deleted the repository in Xcode, I quite Xcode then in the terminal I typed from my home directory ~/username
sudo rm -r .git
Probably not a good idea if there are repositories that you want to keep (which was not a problem for me) but now making a snapshot of an xcode project takes a second and generates a file that is of the order of the Xcode project and not now in the multi GB ball park
the easiest fix is to make sure you have "Enable Source Control" checked in Xcode's Preferences (Source Control tab)

Resources