windows Git 从另一个用户的工作目录中拉取
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4602969/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git pull from another users working directory
提问by paperclip
Is it possible to pull specific files or changes from another users working directory using thier Local IP address?
是否可以使用他们的本地 IP 地址从其他用户的工作目录中提取特定文件或更改?
e.g.
例如
git pull http://192.168.1.101/sandbox/somefile.php
It should be noted that both users are using Windows XP.
应该注意的是,这两个用户都使用 Windows XP。
Thanks,
谢谢,
P.
P。
回答by paperclip
Thanks to the response of both Rup's answer and eckes's answer, I've come up with the following so far:
感谢 Rup 的回答和 eckes 的回答,到目前为止我已经提出了以下几点:
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.
您需要知道用户 PC 的 IP 地址192.168.x.x
(这将在下面的示例中显示),然后您需要在 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.
- 右键单击要在用户 PC 上共享的所需文件夹,然后选择“属性”。
- 选择共享选项卡。
- 选择“共享此文件夹”并为文件夹命名。这将是下面示例中的。
- 单击确定。
On your PC you need to have an initialised and empty git repository for you to add the new remote before you pull.
在您的 PC 上,您需要有一个初始化的空 git 存储库,以便您在拉取之前添加新的远程。
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.
上面的问题是它会复制共享文件夹的全部内容。我仍在寻找一种从另一个用户工作目录中提取单个文件的方法。
回答by Rup
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.
是的,尽管这取决于您拥有的文件共享机制。默认情况下,您的其他用户几乎肯定不会通过 HTTP 托管他们的存储库,尽管您可以根据需要让他们进行设置。您可能想要做的是使用 XP 的文件共享,您可以通过 IP 进行共享,即
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.
如果没有共享目录,但您对他们的机器有足够的访问权限。
回答by eckes
As an alternative to Rup's answer, you could access windows domain boxes using
作为Rup 答案的替代方案,您可以使用访问 Windows 域框
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.
repo
包含.git
目录的文件夹在哪里。从签出的工作副本中提取时,您将无法将push
更改返回到存储库,直到签出不同的分支repo
作为您要推送到的分支。
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.
因此,如果您拉取并希望将更改推送回 branch master
,则在签出另一个分支之前您将无法推送hostname.domain/share/to/repo
。一种工作流程是拥有一个未使用的分支(例如,称为unused_branch
)并hostname.domain
在您push
返回更改之前检查该分支。
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.
更干净的替代方法是在您和其他用户可以访问的计算机上拥有一个裸仓库。在这种情况下,您可以push
不必检出另一个分支,因为裸仓库没有检出工作副本。