Abdul Ahmad
Abdul Ahmad

Reputation: 10021

share git repo between two computers locally

I'm working on an Xcode project and my brother wants to start helping out. I have the .git folder in my Xcode project directory, how can my brother pull / push / commit to / from my computer? Do I have to use OS X server and put the repo inside of there, or is there a simpler way to do this?

Upvotes: 3

Views: 3117

Answers (3)

Dave X
Dave X

Reputation: 5147

Basically, if one can write a ls path or ssh [user@]host:path ls command that would list your repository, then you can use the corresponding git clone [[user@]host:]path [optionalNewName] to clone from it.

Also if he (or you) is working on the same local machine, or has access to the local filesystem, one need only point to either the .git directory or the directory containing the .git directory.

To make clone a repository into another directory:

git clone . ~/2015Archive/repositoryB     # copy pwd's repository elsewhere
git clone .git ~/2015Archive/repositoryB  # same
git clone ~path/path/repositoryA .  #  clone other repository into pwd
git clone /home/brother/2015/projects/CoolProject ~/WORK/BrosCode 
# with ssh from a remote machine 
git clone me@brosmachine:/home/brother/projects/CoolProject WORK/BrosLameCode

git clone me@brosmachine:../brother/projects/CoolProject WORK/BrosLameCode

If you change into the target repository and do a git remote -v it will show you an absolute path to the 'origin' from which it was cloned. If it was a local dir, it will be just a plain, absolute path. If it was accessed through ssh, it will be a ssh [user@]host:path identifier.

Upvotes: 0

user1338062
user1338062

Reputation: 12745

If you want to push code between two non-bare repositores, I recommend having a look at git-annex.

It is usually used for syncing large files between repositories, but it also contains a nifty way of syncing non-bare repositories (pushes go to synced/master branch that is automatically merged).

Upvotes: 1

rjmunro
rjmunro

Reputation: 28076

One simple option is to enable "remote login" in sharing, which enables ssh, then you can use the ssh protocol to clone the repository. Remote login preferences will tell you:

To log in to this computer remotely, type "ssh [email protected]".

[email protected] will be replaced with your username and hostname. In terminal, use:

git clone [email protected]:[path]

on your brothers computer to clone the repo to him, where [path] is the path to the folder containing the repository. You will need to enter your password, and you will need to enter it in order to copy changes back later with git push or whatever.

You can set up passwordless ssh with private keys, but bear in mind that by doing this you are effectively giving your brother entire control of your computer.

Upvotes: 3

Related Questions