removing local git repositary from Xcode Project? - xcode

I had selected local git repositary when I created xcode Project.
But when import to SVN and commit, it commits locally not in SVN.
How can I resolve this problem? I want to remove all hidden local git files from the Xcode project without affecting source code? any help please?

Open Terminal and Type
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
open the project in finder
delete the .git
Good to go. Enjoy

Open the folder the project is in, hold down Cmd, Shift, . (period) and you will see a folder named ".git". Delete that folder, and you're good. Hide hidden files again by holding down Cmd, Shift, . (period)

You can find the solution in this question:
How to fully delete a git repository created with init?
You really should try google first before asking on SO.

The local git repository is stored in a folder named .git inside your project folder. It's hidden (any file/folder starting with a . is) but you can delete or move it using the Terminal. Once it's gone, your folder will no longer be recognized as having a git repository.

Related

Visual Studio new Project with wrong git repository

When I create a new project, I connect it with the git source from another existing project, this one is totally new and I don't know why it takes the sources control from the other ones without asking or anything.
For example, I have my project "A" on my computer, connected with git, today I tried to create project "B", and from the beginning, it connects with the git from the project "A", and says that I have tons of changes.
How could I avoid that o change it?
You can delete the .git folder or you can simply change the repository URL as below
Changing a remote repository's URL
The git remote set-url command changes an existing remote repository URL.
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
Looks like there's a .git folder in your new project directory. Try deleting that and it should work when you connect it again.
I had the same issue and I know how to solve it. For some reason, VSC (Visual Studio Code) has the wrong path for the git folder.
How to fix it:
1.
When you hover your mouse here:
you will see that path (mine pointed to the whole desktop). Delete it in explorer.
2.
In my case, that was all I needed to do. After that VSC found a proper git file.

Xcode merging issue

I am attempting to merge two branches, but I have four files with a "C" icon at the side of the file name, like the following:
No matter how I click the file, I cannot open it.
Meanwhile, the bottom right "Merge" button is inactive, and I am guessing that the cause for unable to select "Merge" is the icon beside the file name. Can anyone tell me what does that sign mean? And If resolving the problem with the "C" icon is enough to make the "Merge" button active so that I can merge two branches successfully?
After I click on the "C" file, and then click on some other files with A, there is a message says:
The source control operation failed because the file “XXX” could not be found. Make sure a valid file exists in the repository and try again.
I understand that I added some new files that the other branch does not have, so I guess this is the other cause for me not able to merge the two branches? However, I am confused that, if I were to fix the alert and the new file exists in the repository, doesn't it mean that I actually successfully "merge" the two branches, sine the old branch would then contain the new file? Could anyone provide any insight in this?
https://stackoverflow.com/a/20033446 helped me solve this. There was an untracked file causing the issue. The file was there on both tracks but somehow it wouldn't work.
What I did was the following:
Add the problematic file name to the .gitignore in both repos
Close Xcode
cd into main branch
git rm -r --cached .
open the project, change a file and commit.
Exit Xcode to do git add .
Open Xcode and commit again, push
cd into the problematic branch
git rm -r --cached .
open the project, change a file and commit.
Exit Xcode to do git add .
Open Xcode and commit again, now pull
Do a change, commit and push.
Now in your main, pull once again.
Both dirs are now on the same state. Edit your .gitignore file to add the problematic file back in, push from this dir and pull from the other dir.
Now both have the same clean state with the problem file included.

When I try to drag and drop a folder which contains a git repository (which is a submodule at the moment) it says "Can't drop folder here..."

In the git-windows-interface when I drag and drop a repository it says: "Can't drop folder, You can only drop one folder without git repository with the app at this time. Dropping a single folder will allow you create a new Git repository in that location...".
How should I add a git repository to the git-windows-interface?
thanks
You can try and make GitHub for Windows detect your repo, by modifying the local path(s) it scans.
That would avoid trying that "drag and drop feature" which might not work in your case (being a submodule, which is by nature a nested git repo).
If it isn't possible to change that path, at least try and copy that repo in %HOME%\My Documents (HOME being set by the portable git within GitHub for Windows, C:\User\login on W7+, C:\Document and Settings\Login on WXp).
Then a local scan will detect it.
I was getting the same error. I had been trying to drag in the hidden .Git folder. Instead, drag in the folder above, which contains the .Git folder.
This worked for me:
Rename the ".git" folder to ".git_back"
Create a new git repo in the same folder so the new ".git" folder is in the same folder as the old one.
Close github for windows, delete the new .git folder and rename the old one back to ".git"
Open github for windows again, and it will see the old ".git" folder.

xcode commit missing file or directory

I'm not sure what happen but when I try to commit my changes in Xcode I get an
fatal: Could not switch to '/Users/charlesbutler/xCode/MA Mobile/MA MobileTests': No such file or directory
I have a bunch of files like this.
Is there anything I can do to remove them from being committed. A lot of them were deleted (probably manually in the project folder by me)
This just happened to me. I had deleted a folder with contents from the project folder. Xcode didn't handle that well.
What worked to fix it was to recreate an empty folder with the same name. No need to recreate its contents.
In your case I think you just need to create a new empty "MA Mobile" folder in the same location the old one was. Then commit. It worked for me.
After the first commit I deleted the new folder, then committed again. It seems that Xcode is missing the logic to handle the deletion of a whole folder with contents.
If you'd like to simply commit all changes you made, doing so through the Terminal should fix the problem.
Open the Terminal App and cd into your project directory, once there type in the following command:
git commit -a
Enter your commit message by pressing 'i' and typing it in, then press 'Esc', then ':', and type 'wq'
All done, you're problem should be fixed.
Jader Feijo's answer solve my problem.
Just want to suggest an easier way to add comment, without all this additional Vi steps, by simply adding -m parameter:
git commit -a -m "Commit Message"
Assuming that you are using GIT - run the following in your command line;
cd "/Users/charlesbutler/xCode/MA Mobile"
git rm -r "MA MobileTests"
I had this problem after adding and then deleting sub-projects in a project that was under source control.
I fixed it by using the GitX application, selecting the Commit View, un-staging the now non existent files from the Staged Changes list, and then selecting Discard Changes for the same files in the Unstaged Changes list.
I then had to delete the repository from the Xcode Organiser-Repositories screen and restart Xcode before things were working ok again. Xcode automatically re-adds the repository back in when the project is re-opened.
Perhaps someone with GIT expertise can provide a command line alternative that performs a "Discard all changes that are no longer present on disk" action
I've had this problem because somehow a folder of the project was added to .gitignore, I removed it from there and committed the missing files. Xcode did not show me that the folder was in gitignore or that he was different from the other folders in any way.

Create git repository after project creation

I know there's an option to make a local repository for your project when you first create it, but is there an option create a repository after you've created your project?
Sure, just run the following command in your project directory:
git init
This will create the .git directory containing an empty repository. Then, add and commit your files.
In the command prompt, make sure you're in the desired directory and perform a git init and you will have created an empty repository.
You can then proceed to add the files and directories to the repository by doing
git add <filename1> <filename2> ...
or you can select whole directories and use * to act as a wild card of sorts.
git add ./*
If you have any more questions check out these pages:
http://gitref.org/creating/
http://gitref.org/basic/#add
Hope this helps.
You should go to your Xcode menu, click Source Control > Create Working Copy...
Xcode will automatically create your .git folder repository.
Good luck, and make sure you have a backup of your project before trying something else.

Resources