Reputation: 83
I want to use Git over the local network in our company because I don't have internet access in my computer. My friend has an internet connection and an ubuntu machine, he pushed some source codes to Git and I need to pull them without Internet connection and I also use ubuntu 14.04. Additionaly, I set up a repository with the command:
git init --bare
EDIT: Both machines are ubuntu, sorry for the misunderstanding.
Upvotes: 1
Views: 3995
Reputation: 51403
In addition to my previous answer...
Your friend can use git daemon
on his windows machine to export the repository
On the windows machine do this in the git bash
git daemon --export-all --reuseaddr --verbose --enable=receive-pack --base-path=PATH_TO_THE_REPOSITORY
On your ubuntu machine you can than clone the repo
git clone git://your_friends_ip_or_computer_name REPO_CLONE_NAME
or add it to your existing repo as another remote repository and pull his changes
git remote add my_friends_repo git://your_friends_ip_or_computer_name
git pull my_friends_repo master
touch git-daemon-export-ok
Upvotes: 2
Reputation: 26555
A git repository is not much more than a box. You can put your code in in it (commit), you can send a copy of the content to another (remote) box (push), and you can fetch the content from another box to your own box (pull).
If your friend pushed his content to some box in the internet (like github) and you cannot access that location from your host, this box is not helpful in your case.
You have a few choices:
As you are using ubuntu which already comes with ssh, maybe the easiest solution is setting up a new user on your box and create a bare repository there. Then you have a place to pull from an your friend can use that user to push to that repository.
You can do this like this:
sudo useradd -m gituser # create user
sudo -iu gituser git init --bare reponame # create repository
sudo passwd gituser # set password for user
Afterwards your friend can push to it using git push gituser@yourhost/reponame
. And you can get the pushed content with git clone gituser@yourhost/reponame
.
Another way is to use git-daemon on your friends host to serve his repository. In this case you can pull directly from his host. On windows type:
git daemon --base-path=PATH --export-all
where "PATH" is the local directory containing the repository. On ubuntu you can access that repository using
git clone git://friendshost/reponame
where "friendshost" is the hostname of your friends host, and "reponame" is the name of the directory containing the repository. For example if the repository is located at "C:\some\dir\repo" then "C:\some\dir" is the PATH and "repo" is the reponame.)
Upvotes: 1
Reputation: 51403
Ask your friend to create a windows share for the git repository.
Ensure that you have installed
apt-get install cifs-utils
create a mount dir
$ mkdir ~/my_friends_repo
mount the remote share using
$ sudo mount -t cifs -o username=USERNAME,password=PASSWORD \
//your_friends_ip_or_computer_name/NAME_OF_SHARE ~/my_friends_repo
Now you can either clone it
git clone ~/my_friends_repo my_friends_repo_clone
or add it to your existing repo as another remote repository and pull his changes
git remote add my_friends_repo ~/my_friends_repo
git pull my_friends_repo master
Upvotes: 3