将 git 更改推送到共享网络驱动器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11635493/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 14:13:04  来源:igfitidea点击:

Push git changes to a shared network drive

gitnetworkingpushshareddrive

提问by user1549303

How can a team of four people use Git (specifically Github for Windows) to push local changes to a shared network drive?

一个四人团队如何使用 Git(特别是Github for Windows)将本地更改推送到共享网络驱动器?

Right now (without Git) we have to copy the files from the network drive to our local machine, edit the files, and then re-upload them to the shared network drive. This is a painstaking process that can lead to lots of errors, but it seems like something Git could help us with.

现在(没有 Git)我们必须将文件从网络驱动器复制到我们的本地机器,编辑文件,然后将它们重新上传到共享网络驱动器。这是一个艰苦的过程,可能会导致很多错误,但似乎 Git 可以帮助我们。

Can we simply install Git on the shared drive and go from there?

我们可以简单地在共享驱动器上安装 Git 并从那里开始吗?

回答by Tony Eichelberger

Not sure if you found something that works for you or not, but I have a writeup on how to do that very thing on a windows network drive:

不确定你是否找到了适合你的东西,但我有一篇关于如何在 Windows 网络驱动器上做这件事的文章:

http://tony.halcyonlane.com/blog/2011/09/22/Using-git-at-work-on-a-Windows-network-drive/

http://tony.halcyonlane.com/blog/2011/09/22/Using-git-at-work-on-a-Windows-network-drive/

From a cmd prompt change to your mapped drive.

从 cmd 提示更改为您的映射驱动器。

$ cd g:

$ cd g:

Then cd into your soon to be git repository.

然后 cd 进入您即将成为 git 存储库。

$ cd scripts

$ cd 脚本

Then create an empty git repository. If you do not use the --bare option, you will have issues so don't leave that out.

然后创建一个空的 git 存储库。如果您不使用 --bare 选项,则会遇到问题,所以不要忽略它。

$ git init --bare

$ git init --bare

Now if you don't have a local git repository yet, then you can clone your new repository wherever you like by navigating back to your local drive.

现在,如果您还没有本地 git 存储库,那么您可以通过导航回本地驱动器来随时随地克隆您的新存储库。

$ c:

$ cd work/scripts

$ git clone file://g:\scripts

$c:

$ cd 工作/脚本

$ git clone file://g:\scripts

When you clone, you automatically get a remote called "origin" and you can push to the server for safe keeping any time you make changes locally.

当您克隆时,您会自动获得一个名为“origin”的远程,并且您可以在本地进行任何更改时推送到服务器以安全保存。

$ git push origin master

$ git push origin master

If you already have a git repository and you just want to push out to the shared drive then you can do this from within your local git dir.

如果您已经有一个 git 存储库并且只想推送到共享驱动器,那么您可以从本地 git 目录中执行此操作。

$ git remote add origin file://g:\scripts

$ git push origin master

$ git remote add origin file://g:\scripts

$ git push origin master

回答by eykanal

Our team currently does exactly this. Every developer has the following:

我们的团队目前正是这样做的。每个开发人员都有以下内容:

  1. Git installed on their local machine
  2. Access to their own personal shared drive (L:)
  3. Access to a shared group drive (V:)
  1. Git 安装在他们的本地机器上
  2. 访问他们自己的个人共享驱动器 ( L:)
  3. 访问共享群组云端硬盘 ( V:)

We have the "remote" repository (set up using init -bare) on the V:drive, and everyone has a clone on their personal L:drive. All changes are made to the L:drive and pushed up to the V:drive, which are then pulled down later by the other developers to their respective personal repositories on their L:drives. This works without any problems, and mitigates the need for a Git server.

我们init -bareV:驱动器上有“远程”存储库(使用 设置),每个人在他们的个人L:驱动器上都有一个克隆。所有更改都对L:驱动器进行并推送到V:驱动器,然后其他开发人员稍后将其下拉到其L:驱动器上各自的个人存储库。这没有任何问题,并且减少了对 Git 服务器的需求。

回答by bluesman

You can add another remote pointing to your network drive (git remote)

您可以添加另一个指向您的网络驱动器的遥控(git remote)

Then you can push pull similar to what you do with github

然后你可以推拉类似于你对github所做的