How to resych xcode and Git - xcode

I had a power failure while using xcode. I use Git and Time Machine. When my machine came back up, and I restarted xcode, most of my project files are marked with a status of '?'. There are some that are incorrectly marked as 'M'. I tried doing a commit but got an error consisting of a list of my project files that were supposedly not being tracked by Git (the list was not correct) and the commit failed.
After reading some entries on SO I exited xcode and tried
git stash
git reset --hard cf530af
git stash pop
This left me with short list of modified and deleted files which was correct. But when I restarted xcode the file stats icons were unchanged.
Next I exited xcode and restored last night's Time Machine backup. That went smoothly, but when I restarted xcode, the file status icons were still incorrect.
At the moment, git status shows results I believe to be correct. git fsck shows a number of dangling blobs and 1 dangling commit.
What do I need to do to resynch xcode and Git so I can git back to work?

Related

What should I do when Xcode says a previously commited file is unversioned?

Occasionally, Xcode shows "File is Unversioned" in the Version Editor (and shows a question mark by its name) for a file that has already been updated and committed several times in the past. If I go ahead and commit the file again, Xcode then shows the complete history in the Version Editor. I did not rename or move the file when this happens.
Is there a way I can force Xcode/git to recognize the file without re-committing it?
I'm currently using Xcode 10.2.1.
I used the command line once
git add .
git commit -m "your commit message"
git push origin main
After that, everything on XCode Source Control worked as per usual.

Xcode source control not synced with git status (and with repo)

EDIT: Thanks #RobMac - XCode restart did solved it. Good luck for all
Looks like a bug...
I Have two files in Xcode that marked in the source control with question mark (so it's untracked files)
When I do git status i get:
On branch develop Your branch is up-to-date with 'origin/develop'.
Untracked files: (use "git add ..." to include in what will be
committed)
Podfile.lock
Pods/
The files are not listed.
I try to workaround in Xcode by right click and "Add "FileName.swift""
Or to commit them in the commit window.
Both do NOTHING!!
When I look at the repo in BitBucket I see the files in their last revision... So It's great...
The problem is only the files status in Xcode
How can I overcome this?
Thanks!
Late answer, but I had this happen to me. This is what I tried without success:
Closed existing project, not Xcode
Made changes on the command line (moved/deleted files)
Used GIT on the command line
Opened up existing project
Everything messed up
List item
I fixed it by completely closing out of Xcode and then opening up project again.
did you check ls -al?
checkout how many .git directories exist
if you have mistake you did git init more than you expect because of xocde

Xcode 7.1.1 Change to SVN from Git, remove Git

I want to get rid of the link to the git repository
As you can see below clicking on source control still shows the old git remote.
I was using both SVN and Git, Xcode was configured with GIT.
What I did was
delete .git/ in Terminal.
Delete Git Repositories from XCode preferences
Add SVN Repository to Xcode Preferences.
Check out a new working copy Using Source Control - Checkout
I have tried adding a new git and setting the remote or deleting it.
What I have done is manually edit the files
.xccheckout
.xcscmblueprint
Which were located in .xcworkspace I found these by grepping
grep -wr git *
I deleted every key value which had git in it.
I am not sure whether I left some superfluous data in it, but so far it seems to be holding up.
As you can see the git part is gone and only my svn remains

How does Xcode know my commit history?

When I started my project I used Git in the terminal to track changes. Then I realized source control is built into Xcode. So I committed all my changes, everything worked well. Then I went to history in Xcode and saw all my previous commits made from the terminal.
How does Xcode know about those commits? Especially since I haven't signed into my Git repo in Xcode.
The Git history is kept locally in the project's .git folder. When you open Xcode, it finds your local .git folder and uses it to show the project's history.
You don't have to push to your remote Git repo for that, since the history is kept locally.

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

I am using git in my projects, whenever I try to pull from Xcode I get "Uncommitted Changes" and it prevents me from pulling/pushing.
I try to commit and find one file with extension *.xcuserstate, this file is modified whenever I open/scroll into any project file in Xcode. That leaves me no option but to do a single commit that contains that file, which fill the git commit logs with meaningless commits.
Is this there is a way to stop this behavior?
I tried to put *.xcuserstate and xcuserdata into git ignore but that caused Xcode to crash every time I try to pull.
This happens with Xcode 4.2 and 4.3
Normally you don't want to put the *.xcuserstate and *.xcuserdata files into your Git repository. These files aren't really part of your project, but are just a place where Xcode stores its local information that is helpful when reloading your project.
You can fix this by using:
git rm --cached *.xcuserstate *.xcuserdata
and then committing the result. This will remove those files from the repository without removing them from your working directory.
If this is a settings file which is different for every developer, you probably don't need to version control it, just remove it from Git.
If that is not an option, you can Git Stash Save your changes before pulling and Git Stash pop to apply them again.

Resources