GitHub - 共享网络驱动器回购

GitHub - Shared Network Drive Repo

大家好,我是 git 的新手,但我们正在尝试在办公室中使用它来跟踪大型 Web 项目的更改。

我们在共享网络驱动器上设置了一个大型网站的网站文件,这是我目前的流程和我面临的问题!

我在 Windows 10 并使用 git 命令行界面。

我 cd 到我们共享驱动器上的这个网站目录并执行以下操作:

$ cd /x/Clients/ClientA/Website/
$ git init
$ git status
$ git add --all
$ git commit -m "Initial Commit"

然后我 cd 到我的桌面并克隆一个本地版本:

$ cd /c/Users/Account/Desktop/
$ git clone /x/Clients/ClientA/Website/

这个克隆非常完美,我现在使用 Atom 在我的 Desktop/Website/ 文件夹中更改一个文件并保存它。

然后我提交这些更改并尝试将它们推送回我的共享驱动器:

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   index.html

no changes added to commit (use "git add" and/or "git commit -a")

$ git add --all

$ git commit -m "Edited file"
[master 76782c6] Edited file
 1 file changed, 3 insertions(+)

$ git push
Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (11/11), 922 bytes | 0 bytes/s, done.
Total 11 (delta 6), reused 0 (delta 0)
remote: Checking connectivity: 11, done.
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: is denied, because it will make the index and work tree inconsistent
remote: with what you pushed, and will require 'git reset --hard' to match
remote: the work tree to HEAD.
remote:
remote: You can set the 'receive.denyCurrentBranch' configuration variable
remote: to 'ignore' or 'warn' in the remote repository to allow pushing into
remote: its current branch; however, this is not recommended unless you
remote: arranged to update its work tree to match what you pushed in some
remote: other way.
remote:
remote: To squelch this message and still keep the default behaviour, set
remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To X:/Clients/ClientA/Website/
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'X:/Clients/ClientA/Website/'

任何人都可以指出正确的方向,告诉我如何设置它,以便办公室中的多个人可以成功克隆并推送到网络驱动器上的那个位置吗?

谢谢!

您正在尝试推送一个具有 "working tree" 的遥控器,现在,在该存储库上,签出的分支就是您尝试推送的分支。反过来想想:你正在分支 X 上工作,而其他人试图推入你的分支 X。你希望 git 限制它,因为这就像从你脚下拉一块地毯,对吧?嗯,就是这样。

非裸存储库不是常见的做法, 正如错误消息所说, 默认情况下未启用。 我建议改用 bare 存储库,而不使用工作树。

您可以从现有 /x/Clients/ClientA/Website/ 创建一个裸存储库,如下所示:

git clone /x/Clients/ClientA/Website --bare /x/Clients/ClientA/Website.git

在此之后,您可以从 /x/Clients/ClientA/Website.git 克隆并推送到它。 但是它不能有工作树。

例如,如果您希望工作树始终与 master 保持同步, 您可以从 /x/Clients/ClientA/Website.git 为它创建一个专用克隆,并且可以在 /x/Clients/ClientA/Website.git 中设置一个 post-commit 挂钩以在专用克隆中触发 git pull