git(osis) and Xcode - xcode

I installed (successfully) gitosis. I want to use it at my debian (rootserver) to access my Xcode projects (and merge, etc.). I'm able to clone the git repo with Xcode successfully, but if I try to push some (committed) changes, Xcode tells me "Choose the Remote to witch to push the changes" But I can't select any. I am able to push via Terminal.app, but that's not very comfortable. So why is Xcode telling me, there are no remotes available? I tried to add the remote manually (it is something like "gitosis#myserver.com:repositories/gitosis-admin.git"), I tried with ssh://gitosis#my..., but this dosen't even work with terminal.app.
So why is Xcode telling me "No Remotes available"?

Go to the organizer, click repositories, click yours, go to remote, click add remote, should be able to add it from there. should ask for verification and such. never used gitosis but that's how it works for git.

Related

How do I sync an Xcode project between two Macs locally?

I have an Xcode project on my MacBook Pro, with a git repository stored locally. I have an iMac also, and I would like the project to sync between the two computers. I understand this is possible with git and source control, but I don't understand exactly how to do it. I also have a USB flash drive connected to my router, which both machines can access. Is there a way to clone the git repository to the flash drive (making it a remote repository?), then have both machines push and pull changes to it? Also, would the flash drive need to be a bare repository? What is the specific terminal code to do this? Thanks.
I found the answer to my question by trial and error. I created the repository file on the flash drive that is plugged in to my router. On the Mac that has the project and git repository on it:
Open Terminal, and type cd. Put a space after cd. Locate the folder you want the git repository to be in (in my case, the one created on the flash drive). Drag it from the Finder window into the Terminal window. It will type out the path to the folder for you. Press return.
Type git init --bare, press return. A bare git repository will be created in the file you specified in the first step.
Type cd, put a space after it, then drag the project folder that you are creating the git repository for into the Terminal window. Don't drag the project file, such as "Test.xcodeproj". Drag the whole project folder that the file is in, such as "Test". Press Return.
Type git remote add origin //. Drag the folder with the git repository you created in steps 1 and 2 into the terminal window. Press return.
The new bare git repository should now be created and linked in your Xcode project as a remote repository. Once that's done, copy the whole project onto your other Mac. To pass information between the two computers:
In Xcode on either Mac, click "Source Control>Commit...". In the lower left corner of the commit window, check the box that says "Push to remote." Click "Commit".
On the other Mac, open Terminal. Type cd, put a space after it, then drag the project folder into the Terminal window and press return.
Type git pull, and press return.
You should now have any changes you committed to Source Control on both Macs.
As of the writing of this answer, when "Source Control>Pull..." is clicked, Xcode crashes. This would be an easier way to pull changes than using Terminal, once that bug is fixed.
As an alternative to a local flash drive or network git repository:
You could setup a remote repository on one of the internet based git servers such as Bitbucket or GitHub (both of which offer free accounts with certain restrictions). Then sync your two macs to the same remote.
This has the additional advantage of providing a third location for your code and additional access methods such as web access or iPad access from an App such as Working Copy.

Add Xcode project to github repo?

I have JUST created a new github repo on the website. Keep in mind that I am a noob but can do basic things in terminal. Anyway, so I just created the repo on my account on github.com and didn't do a single thing to it yet.
So all I want to do is take my Xcode project folder and upload it to my new github repo. How do I do this via terminal?
The best way really is to follow the instructions GitHub gives you:
First, go the correct directory
cd <directory of your Xcode project>
It sound like you've already got a local Git project from Xcode. If that's true, skip this code block.
git init .
git add .
git commit -s
<type in a commit message>
Last, push into your repository. The following is copied directly from my own github account, after I created a new "test" repo. Change the "dhalperi/test" part.
Push an existing repository from the command line
git remote add origin git#github.com:dhalperi/test.git
git push -u origin master
I was just going to leave a comment above but I will also add a summarized answer. My full answer is here.
This isn't via terminal as the question requests, but you can consider this an alternate method. It is well integrated with Xcode now, though, and not difficult to do.
Create Git repository when making a new project
See the answer I linked to above if you already have a project without a Git repository.
Make a Commit
After making a change in your project, select Commit... from the Source Control menu. You will add a short commit message.
Create a new GitHub repository
On the GitHub website make a new repository. Call it whatever you want, but don't add a README or .gitignore or license yet. After creating the new repository copy the link to it.
Add a Remote in Xcode
in Xcode go to Source Control > your branch name > Configure. Then click the Remote tab > "+" button > Add remote. Fill in your repository name and address.
Push your project to GitHub
Go to Source Control > Push. You will have to enter your GitHub user name and password the first time.
That's it. Now any time you make changes in Xcode, all you have to do is Commit and Push.
If you didn't follow this explanation, please read this and this for more detail.
Further Study
This is an excellent video that I recently watched that helped me understand Git and its integration with GitHub much better.
The Basics of Git and GitHub
An easier way to do it in Xcode.
You can even push only one current branch to GitHub or the whole project.
(for Xcode 11)
Just select a needed branch/(or top folder) in "Source control navigator" and right-click on it. Then select "Create remote". Or "Editor -> Create remote".
Then use your account at GitHub to create the repository. If using your GitHub account is not proposed maybe you still not add your GitHub account in Xcode -> Preferences -> Accounts
After everything is set up. Click "Create".
To push your project/branch to GitHub repository click "Source Control -> Push".
After that check Github. All should be there.
Get the Github Mac Application, you don't really need a terminal unless you want to do more fancy advanced stuff ;-)
Simply go to your project page on GitHub, then click on "Clone in Mac", this should automatically download and install it for you. You have to do this at least once to install the app and setup some required permissions.
After that, you'll see the GitHub Application in your Dock, simply open it, then click on that small "+" sign at the bottom, there you'll see "Create New Repository" and "Add New Local Repository".
You can either add the repository that XCode already created for you or download one from GitHub, then open it in XCode.
if you already have a git repo on your Mac and using Xcode 9,
for xcode 9, just go to the source control tab in the navigation inspector in Xcode. right click on the master git and select create "Your project name" remote on GitHub.
give your GitHub credentials and give a name to git repo and Xcode will create and push your code for you.
a non terminal solution is to install SourceTree. Its a GUI thats super easy to use compared to the terminal. But its highly recommended to learn git commands properly.

Why aren't my commits showing up in Xcode 4?

I am a new programmer and trying to use Xcode's source control manager to keep track of changes to my code.
Right now I would like to revert back to a previously committed version of my project. However, in opening the Organizer, selecting Repositories, and selecting my project from the left project list, I can only see snapshots of my project.
The previously committed versions appear correctly when using the Version editor outside of Organizer.
Ideas?
I don't believe you can do this within Xcode but it is simple enough outside of Xcode. The easiest approach would be enter the following in Terminal:
git checkout -b <new branch> <commit>
This won't revert on the current branch but will give you a new branch to develop off of. If you really want to revert then simply:
git revert <commit>
with conflict resolution will work.
If you can't find 'git' within the Terminal then 1) install the Xcode command line tools or 2) look in the Xcode package under Xcode/.../usr/bin to find it.

Xcode 4.4.1: git no longer showing modifications

Suddenly, unfortunately, I can't place the moment of occurrence Xcode has stopped showing git information, nor can I submit/revert/etc via git from inside Xcode. If I check the Organizer's Repositories, my project is still listed with its last commit.
Using the command line: git status, I see all the unstaged changes as I would expect.
So, the project is still under git control, but somehow detached from Xcode.
I was able to fix this issue by going to Organizer in Xcode, selecting my project, and deleting the Derived Data. You may need to quit Xcode and re-open your project after doing this to let Xcode rebuild the project index.
Installing the command line tools worked for me

Xcode/Git Repository Error: "Please verify that the working copy is reachable and try again."

Here are the steps I take.
I open Xcode (4.3.3) organizer and select Checkout or Clone Repository
I choose the location https://MyUsername#bitbucket.org/MyUsername/myrepo.git
Press Clone button and it successfully clones it on my local disk
So I open the local copy of the project and perform some changes to it.
When I try to commit changes (or do any other git related operation) I get the following error:
The working copy "MyAppName" could not be reached.
Please verify that the working copy is reachable and try again.
However I can perform commits (and other types of git operations) without any issues from the Terminal app using command lines.
I've tried restarting my computer, deleting all Xcode settings, but nothing helped.
Update: I tried it again today and it works fine now. Maybe it's some sort of an intermittent bug in Xcode.
Whenever this happens to me (and it happens often) I do the following:
1-Close the project
2-Open the organiser
3-Go into the repositories tab.
If your current working copy has been added to the list already, then within the organizer navigate to it, and double-click on the .xcodeproj project.
This will re-open the project in XCode, and you'll find that now SCM operation will work fine.
If your current working copy hasn't been added to the list, press the + button in the bottom left corner, select "Add Working Copy", navigate to the folder containing the .xcodeproj and open this folder.
Now double click on the .xcodeproj file, the project will open in XCode.
And it's all working fine again...
No idea why this make things work... but it does
I have the same problem. It happens if you have ~/ in the path to project. Works fine, when you open your project from organizer.
It's a bug of Xcode! When you search the xxx.xcodeproj from your Home folder of the dialog box directly, Xcode will use the ~/xxx/xxx as the SVN/Git path which is completely wrong.
So you should avoid this, and search from the "/" path instead.
This is not exactly the answer you might be looking for, but I ran across similar problems when using Remote git repository (Github) and Xcode.
I ended up using a GUI tool "SourceTree", a good and easy to use tool to pull/push your code from Local Git to Remote Git Repository. Try it out http://sourcetreeapp.com/

Resources