4

Is it possible to pull specific files or changes from another users working directory using thier Local IP address?

e.g.

git pull http://192.168.1.101/sandbox/somefile.php

It should be noted that both users are using Windows XP.

Thanks,

P.

paperclip
  • 2,280
  • 6
  • 28
  • 39

3 Answers3

8

Thanks to the response of both Rup's answer and eckes's answer, I've come up with the following so far:

You'll need to know the IP address of the users PC 192.168.x.x (this will be the in the example below) and then you'll need to share the folder in Windows XP.

  1. Right-click the desired folder you want to share on the users PC and select Properties.
  2. Select the Sharing tab.
  3. Select 'Share this folder' and give the folder a name. This will be the in the example below.
  4. Click OK.

On your PC you need to have an initialised and empty git repository for you to add the new remote before you pull.

Example:

git init
git remote add <alias> //<ip_address>/<shared_folder_name>
git pull <alias> <branch>

The problem with the above is that it will copy the entire contents of the shared folder. I am still looking for a way to pull an individial file from another users working directory.

paperclip
  • 2,280
  • 6
  • 28
  • 39
  • 1
    You might want to check this question: http://stackoverflow.com/questions/610208/how-to-retrieve-a-single-file-from-specific-revision-in-git – eckes Jan 06 '11 at 11:01
  • or `git checkout -b ` before `git pull...` then check out your friends progress before `git checkout ` and `git merge new branch>` if you're satisfied with the work of your friend and want to merge it with your own. That is a more common way to work with `git`. Other wise, if you got access to the file of your friend, you don't need git -- just copy. – Mats Oct 30 '16 at 16:16
3

Yes, although it'll depend on what file sharing mechanisms you have. Your other user almost certainly won't be hosting their repository over HTTP by default, although you could have them set this up if you want. What you probably want to do is use XP's file sharing which you can do via IP, i.e.

git pull \\192.168.1.101\shared_directory\sandbox

if there's shared directory set up or

git pull \\192.168.1.101\c$\full_path_on_c_drive\sandbox

if there's no shared directory but you have sufficient access rights to their machine.

Rup
  • 33,765
  • 9
  • 83
  • 112
  • I think I am making some progress but I am still unable to pull a specific file (e.g. ./sandbox/index.php). At the moment it pulls the entire directory. – paperclip Jan 06 '11 at 10:05
  • 1
    That I'm not really sure, sorry. Do you want to import the file with history (and track future updates?) or just the file contents from a specific revision? If it's with history then I expect your best option is to pull your colleague's head branch into another branch in your repostitory then merge the single file across between branches (which I expect is possible - I've never done that, though). If you just want to fetch the current revision of a file you can use git-show http://stackoverflow.com/questions/610208/how-to-retrieve-a-single-file-from-specific-revision-in-git – Rup Jan 06 '11 at 10:13
3

As an alternative to Rup's answer, you could access windows domain boxes using

git pull //hostname.domain/share/to/repo

where repo is that folder that contains the .git directory. When pulling from a checked out working copy, you won't be able to push your changes back to the repo until a different branch is checked out on repo as that one you want to push to.

So, if you pulled and want to push changes back to branch master, you won't be able to push until another branch is checked out on hostname.domain/share/to/repo. One workflow is to have an unused branch (e.g. called unused_branch) and check out this branch on hostname.domain before you push your changes back.

The cleaner alternative would be to have a bare repo on a computer that you and the other users have access to. In that case, you can push without having to check out another branch before since bare repos have no checked out working copy.

Community
  • 1
  • 1
eckes
  • 64,417
  • 29
  • 168
  • 201