My project disappeared when I renamed it in git - xcode

I was putting the finishing touches on a project. One of those "finishing touches" was renaming the project. Now it's "gone". 😩🔫. I looked on GitHub and it's still "there", but I'm in over my head in terms of how to get my master and my renamed branch to interact properly. Here's how I got to this dreadful state:
I followed Apple's How to Rename a Project post:
In git, from the command line, I checked out a branch to rename the project as follows:
git checkout -b rename-project
When I was done, I typed:
git add .
git commit -m "Renamed my project"
Then, I went back to the master to merge the 'rename-project` branch as follows:
git checkout master
Project /Users/me/Documents/Developer/My Renamed Project.xcodeproj cannot be opened because it is missing its project.pbxproj file.
How do I get my 2 weeks' work back?

master doesn't have your renamed project yet. Close XCode, then do
git merge rename-project
and if that succeeds, you can reopen XCode.

Related

Xcode 14.1 automatically modifies the project.pbxproj file. How to discard this change?

I am running one iOS/Swift project in Xcode 14.1. Git showing project.pbxproj file modified. A few days back I merged some branches and pushed the changes. The branch is working for others but causing an issue for me. Even I did not modify any file after the push. I want to discard this local change. Please help me.
I tried to remove the changes with help of the following commands.
1. $git checkout .
2. $git clean -d -f
The change is disappear for a second after executing git checkout . but again shows the same changes after some time. After running the checkout terminal show the *Updated 1 path from the index* message. I tried to discard changes from the source tree but after refreshing it again showed modify.
Git difference is showing same file is added and deleted on same folder location.
I tried all the ways mentioned here
How do I discard unstaged changes in Git?
But does not work anything for me.
My Solution:
Solution 1:
I deleted the repo and took a fresh clone.
Update
Found another solution also, most of the time it works for me but in case it does not work for you go for the first solution.
Step 1:
Quite the Xcode
Step 2:
Discard the project file changes from either terminal using git checkout . or any UI tool.
Step 3:
Open your Xcode project. Hopefully, you will not get project file changes.

Why doesn't Git track files modified in Xcode?

I'm using Git on the terminal to commit changes & push them to a remote repo.
Git can recognize when I create a file or modify a file via VS Code. However, when I work on my files on Xcode and save them, Git doesn't track any changes. It tells me:
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
What's the problem and how can I fix it?

The working copy <Project name> failed to commit files. - The repository has an uncompleted operation

I've just updated my Xcode from 6 to 7 (and code from Swift 1.2 to Swift 2.0) and try to create new branch in Xcode. After that I can't push my code to Bitbucket.
Is there a way how can I delete repository from directory and setup Bitbucket again and maybe push to another (a new one) repository? Fix of this problem will be great, but I will be satisfied even with move to another repository.
I had this error in xcode 7.1 on a year old project that was working fine. In my case I have a project with the default local repository created by xcode. For anyone who is not going to re-install and re-setup. It is possible to find out what the dangling command is and fix it from command line.
To find the dangling command Open Terminal from the project directory:
xcrun git status
In my case the status returned:
On branch master
You are currently rebasing.
(all conflicts fixed: run "git rebase --continue")
To fix the problem I used:
xcrun git rebase --skip
In my case I ran git status which revealed that You are currently bisecting. (I was doing a bisect and must had forgotten to reset). I did a git bisect reset and attached the head to my latest commit and it was all fine afterwards.
When I am merging from currentBranchA into branchB, I got conflicts,I didn't want to solve the conflicts immediately and quit the merging process. But when I try to merge again, the Xcode shows "The working copy is currently in the middle of another operation..."
I opened the terminal ,cd to the project directory, and check the git status:
git status
it shows:
On branch currentBranchA
Your branch is up to date with 'origin/currentBranchA'.
All conflicts fixed but you are still merging.
(use "git commit" to conclude merge)
Just do it as it says. Continue to input
git commit and click Ctrl + C to close the commit message window.
The problem will be zero.
The problem was with installation of GitHub. I had a master repository. After reinstall and resetup everything works like before.
EDIT: For anyone who has a problem with Xcode and GIT I have a best advice. Don't use it. Use for example Source Tree
When you start developing for a living, you are gonna have to use more reliable solution for GIT. Imagine you have 70 branches. Using Source Tree you can easily solve conflicts and other things about working in team. Xcode GIT solution is not reliable and you are gonna be only frustrated.

How to restore version control in XCode?

I have just recently backed-up my XCode C++ project on my pendrive, using
rsync -avu
Since then, the version control for my project is grayed-out on every files, I can modify the files and not see the "M" nor the "A" sign. The only files still having version-control working "shared" files for which it works correctly. (Those shared files belong to a different project called "Shared").
I have tried git commit -m, git add . and even git init where the files were. Nothing worked.
Can you please help restoring version control for my project?
UPDATE:
Answers for the questions in commens (and answers):
my git repository is on my local hard drive.
I went to the Organiser-repository pane in XCode and I see my recent git commit -m "sth" as "sth" az a commit. I have a single branch: master.
Im not sure what command would be good to test git, as my commits work (theoretically).
I have a folder named .git in the project folder.
git log is working, showing the same as XCode Organiser-repository pane.
I think the XCode just can't synchronise with the git for some reason, and I don't know how to correct that.
First off, this is not an answer that will fix your problem, I just try to provide some help that might get you closer to a diagnosis.
Git stores its files in a folder named .git. Check if this folder is present in your project. If it's not then your Git repository is gone.
Next, try some basic command such as git log. For this to work, you must first cd to your project folder (or a subfolder thereof), because whenever you run a Git command it will look for the .git folder in the cwd or a parent folder. If git log does not work then your Git repository is broken in some way. Someone else will have to step in to further diagnose the problem, as I am no expert on this subject.
Finally, you should also check whether your rsync command has really sync'ed your project's .git folder with the backup's .git folder. Use this command:
diff -rq /path/to/project/.git /path/to/backup/.git
If there is no difference (as I would expect if rsync has worked correctly) then the problem with your Git repository is both in your project and in your backup. If there are differences then it might be worthwile to try your next steps on a copy of the backup (it should be fine to make the copy in the Finder).
Good luck.

Moved file location in Xcode 4, can't push to Github

Git newbie here. Using Xcode 4.3.2. Had to move my project file directory. Commit still works fine but when I do a git push, I get Everything up-to-date, which is incorrect.
How do I get back on track?
Thanks
Check also if you are not in a DETACHED HEAD mode.
That happens if you checkout a tag or a file (see git checkout illustration in gotgit):
That was the case for the XCode question "Git (no branch) in xcode"
When you moved the project directory, did you move the .git folder with it? An easy way to check is to run git log and see if all of your previous commits are still there.
If you moved the .git folder with the rest of the files, then your remotes would still be setup correctly.
If it really isn't hooked up for some weird reason, try running git remote show origin and check to make sure that the url is correct and everything.

Resources