Creating a remote GIT server on the OSX client (Snow Leopard) to synchronize with the local <x20> using Xcode 4

For those who want to create their own git repository in a remote OSX Snow Leopard client window, then synchronize it with SSH with XCode 4.1 - read on.

I managed to get this to work, but I think it can be useful for others who are now pulling their hair in the same boat that I was in, to read all the steps that I took and for someone more experience, than me, to indicate where I can do something better (and possibly include any useful screenshots, etc.).

I just successfully created a working remote git repository on the fallback Snow Leopard MacMini and tested its synchronization with XCode 4.1 with the local git repository (default local repo for Xcode); Unfortunately, it turns out that LOT you have to get the right for this to work: but it works!

Preliminarily: To avoid confusion for those who are not familiar with git (as far as I know) git is git ... this means that there is actually no special version of the server and client version ... for the most part, git installed locally on your computer when you installed Xcode is almost the same as on the "server". The only significant difference is the software / infrastructure support that runs on top.

This is an optional separate layer that the server can use to allow users to connect to the git base system, which makes most of the difference between the git server (aka "remote") and the git client. "Do people connect using the web interface running on Apache ? Do they work using a different type of media user interface (like Gitolite) or just connect to git directly via SSH using the actual OSX user accounts on the remote server? Is this important if you are new to git and trying to configure your own remote server: direct or indirect access.

This note assumes that you only work with a small number of well-known users and, therefore, do not need an additional intermediary level, and therefore we will choose direct access to SSH using real OSX accounts. Also note - this is NOT about synchronizing with GitHub, there are many notes on this topic in other places.

But before we go any further, are you sure you just want to use OSX Client accouts and not a separate user mediation level? (e.g. Gitolite / Gitosis, etc.) ... keep in mind that for direct access, every user who needs to access the server in the future will need to create an actual OSX client account in System Prefs ... if this is not so much trouble, great, otherwise check out Gitolite as it avoids this problem in the long run (but adds an additional level of customization in the short run → https://github.com/sitaramc/gitolite/ ).

SECTION 1 . Configure OSX git server.

I assume that you do NOT have Xcode installed on the remote OSX git box, so you have to download and install git, fortunately, this part is easy ...

From a real remote window, go to http://git-scm.com/ and get git, open the disk image, then run the installer.

Remember to also run the “setup git path for non-terminal program.sh” shell script that comes with the installer (probably next to the installer on the disk image) ... unfortunately, this is not a comprehensive magic link fixer if you do what we are, but he takes care of some headaches for the account that made the installation.

CREATE USER COUNTERS:. Since we DO NOT use the intermediary access level, you will create user accounts directly in System Preferences in a remote OSX window for all users who will use this service.

Create an OSX user group that will have access to the repository (repositories) and add these users to this group.

In the remote window "System Preferences" → "Sharing", enable "Remote Login" (this is SSH), you also have the option to allow access only to specific users ... (more on this service later - how to change it too)

Verify remote login from the local computer using a previously set personal account:

ssh yourname@remoteGitBox.com

If you are logged in or offered to create an rsa key, it means that you connected, great, but only create keys for the accounts that you plan to personally use.

If the machine is behind a firewall, port 22 may NOT be open (for a good reason!) You need to somehow access the machine through this port or one of them, which you will choose below ... without controlling your firewall, this there may be pain - no matter what is lower on it.

On the remote computer, create a master repository shared directory in / Users / Shared, something like / Users / Shared / git ... it's probably best not to draw too much with naming.

Now create a subdirectory in this directory, call it / Users / Shared / git / Test1 or whatever name you like.

In the terminal on the remote computer, go to the directory that you just created (/ Users / Shared / git / Test1) and create the first remote git repository, you do this by attaching "git - -bare init" from the command line, from the inside of this directory, it creates all the necessary repo files. There are notes on the meaning of this invitation ... but for now, we just want you to connect and work, although obviously you should take the time to find out about these tips at some point.

In the Finder GUI on the remote box (usually easier in the OSX GUI as perms can get whacky compared to the standard UNIX), select the / Users / Shared / git folder, get information about it and give read access to / entries to this directory and all auxiliary devices, to the repository access group that you created earlier in the OSX system settings. A quick way to make changes recursively to all subfolders is to unlock the information panel and click on the small gear symbol at the bottom - select "Apply changes to closed items ..."

GREAT SECURITY:. As stated above, if you do not want every bot on the Internet trying to overtake its own path to your repository, you MUST change the remote SSH port of the server from 22 to anything else ... honestly, there are bots all over the network, which do nothing but sniff for open port 22. Changing the port # is hardly a bee’s knee for security - BUT - this will save a lot of firewalls from the log, because otherwise each bot will find you almost instantly and start brute force attacks .

Changing SSH port on remote OSX git:

On your firewall, open a trial number to some TCP number that is convenient for you - to get a list of available TCP ports, go here and select something not in the list: http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

To change the SSH port, you will need to open /System/Library/LaunchDeamons/ssh.plist, but first make a BACKUP of this file !!!! Then open it in your favorite text editor. (this requires administrator permission to edit); you’ll have to add a “listener” to the list ... this is what I did, and after much suffering and suffering, it worked:

/System/Library/LaunchDeamons/ssh.plist changes

Unfortunately, storing SSH on an OSX client with key commands is a scientific project, so you have to go back to the system prefix → exchange, then turn off and then turn on “remote login” or just restart the window - don't worry if you do it right , you will have a standard SSH port open to everyone behind the firewall, and a new port that you can connect to, which the firewall will point to someone else.

To test the new port, enter it on your local computer ssh -p 65534 you@remoteGitBox.com, as I am sure you guessed it, 65534 is the place for any port number you have selected.

Create any necessary ssh keys again if you are prompted to do so - but only for your account! If you cannot log in via SSH through the new port, have you forgotten to restart the service or machine? You MUST get this job before anything else works!

Next, you will have to deal with obtaining all the necessary Alias' rights on the remote box - if you do not, you will receive a message about the mysterious "git-upload-pack" when you try to click on the remote repository in Xcode.

In the terminal, as an administrator in the remote field, change the directories to / usr / bin /

Then in the terminal, enter the following command: sudo ln -s / usr / local / git / bin / git *. (yes, include it in this period), this path will work if you used the default git installer, if not, you will need to enter sudo ln -s / [path / to / git] / bin / git *. this will require administrator access. (you will be prompted for a password)

So here is what you have done so far:

  • Git installed
  • Repository setup
  • Configure the necessary paths to this repository, including some custom links
  • User Accounts Created
  • Created a group for these accounts and granted read and write permission at the file level in the repository
  • Created a new port for SSH on
  • Your firewall has been changed to point to this port (if you are not crazy, never open port 22 to the Internet)

Ok now on xcode on the local machine

I would recommend creating a new test project ... actually not as important as you call it TestProject1 ... but as you go through the template to make it, be sure to create its own local git (this is an option in template creation time in the dialog box). (Much of this is described elsewhere on SO, but to keep the links you're already used to, I will continue)

Now we need to tell Xcode on your local computer about the remote repo and synchronize it.

In Xcode on your local computer, go to Window-> Organizer

Scroll to the left and find the new project that you just created.

Click on the folder called "remotes"

This will open the deleted page in the right pane at the bottom of the page, click the "add remote" button

This will open the dialer in the namespace, enter something for reference ... this is NOT a URL, so it can be short but somewhat descriptive: for example, "MacMini_Test1"

Everything isn’t so simple in the location field ... you need to enter the correct URL into the remote box we just installed ... it can be a pain, but if you do it right, you will print something like this

ssh: //you@remoteGitBox.com: 65534 / Users / General / git / test1

and it should work! Notice how we include the port number after the address, and then the full repo path

Click the "Create" button, and a new prompt will open asking for the SSH password ... enter it.

Sometimes Xcode seems to be stuck here and you need to reboot ... unfortunately, sometimes you made a mistake in the URL and look exactly the same ... regardless if you did everything right above ... at least after rebooting, everything should be good

Exit the Organizer and return to the main Xcode window ...

Write any small comment in the code file, save it, just to change it ...

Commit any changes to the local repository, as you usually do (M will appear next to the file name in the file list after saving it with a new comment, press "Ctrl" on the file and follow the menu to commit the change to the local repo): you must make any local changes before you can push these changes to the remote repository.

Clicking on a remote repo

Go to the file menu, select "File" → "Source Control" → "Start"

The menu should go down, and after the second or so check, a green light should appear, and next to it the text "Online repository" with the name of the repository in the drop-down list "MacMini_Test1" will be displayed if you went with the name above.

Select the "Push" button ... your changes should be transferred to the remote repo.

You have done Sooooooooooooooo!

I apologize for not having time to get more graphic data with this “practical” way, and many other people in this system have provided key information for this, it’s hard to start the listing (in short, my apologies - For now moment, I will add even more benefits over time). Whatever ... this is what you need to do to create a personal git server running on OSX Snow Leopard, behind a firewall on a custom SSH port, in order to associate the project with Xcode 4.1 or higher.

Phew!

+8
git ssh xcode macos
source share

No one has answered this question yet.

See related questions:

15981
How to delete a Git branch locally and remotely?
4105
How to move a new local branch to a remote Git repository and track it?
2990
How to create a remote Git branch?
904
How to compare local git branch with its remote branch?
854
Git for Beginners: The Ultimate Practical Guide
773
How to force push git?
658
How can I resolve git saying “Commit your changes or hide them before you can merge”?
521
How to change the remote branch being tracked?
468
Various ways to remove local Git changes
252
Synchronizing local Git repository with remote

All Articles