问题
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.
回答1:
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.
- Right-click the desired folder you want to share on the users PC and select Properties.
- Select the Sharing tab.
- Select 'Share this folder' and give the folder a name. This will be the in the example below.
- 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.
回答2:
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.
回答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.
来源:https://stackoverflow.com/questions/4602969/git-pull-from-another-users-working-directory