GitHub - 共享网络驱动器回购

Kiw*_*ood 0 git github network-drive

嗨伙计我是git的新手,但我们正试图在办公室使用它跟踪大型网络项目的变化.

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

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

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

$ cd /x/Clients/ClientA/Website/
$ git init
$ git status
$ git add --all
$ git commit -m "Initial Commit"
Run Code Online (Sandbox Code Playgroud)

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

$ cd /c/Users/Account/Desktop/
$ git clone /x/Clients/ClientA/Website/
Run Code Online (Sandbox Code Playgroud)

这完全克隆,我现在使用我的桌面/网站/文件夹中的Atom更改文件并保存.

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

$ 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/'
Run Code Online (Sandbox Code Playgroud)

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

谢谢!

Sto*_*ica 5

对于非裸存储库而言,这不是常见做法,并且正如错误消息所述,默认情况下不会启用此功能.我建议使用存储库,而不使用工作树.

您可以从现有的/x/Clients/ClientA/Website/这样创建一个裸存储库:

git clone /x/Clients/ClientA/Website --bare /x/Clients/ClientA/Website.git
Run Code Online (Sandbox Code Playgroud)

在此之后,你可以克隆/x/Clients/ClientA/Website.git,你可以推动它.它虽然没有工作树.

例如,如果您希望工作树始终保持最新状态master,则可以为其创建专用克隆/x/Clients/ClientA/Website.git,并且可以设置提交后挂钩/x/Clients/ClientA/Website.gitgit pull在专用克隆中触发.