如何不使用远程连接几个本地git repos?

时间:2019-02-17 19:27:28

标签: git

在我的本地PC上,有一个Web项目的仓库(A)。在同一台PC上,我有该项目的多个部署(B,C),有时在这些部署中开发和测试新功能会更方便。

我想知道如何通过git连接这些部署以使用相同的代码库(但创建不同的分支)。一种方法是使用公用远程仓库,将更改(从A)推送到那里,然后将更改拉回到另一个本地仓库(B),但理想情况下,我想更新那些无法访问远程仓库的文件(通过执行git命令,例如git pushgit pull)。 git有可能吗?还是我必须安装类似git service的东西?

我试图通过以下步骤来实现torek的建议:

  1. 在一个文件夹中创建了两个文件夹“ repo1”和“ repo2”,我们称其为“ D:\ path \ to \ repos”
  2. 在两个(git init中都
  3. 初始化了git
  4. 在repo1中,创建了一个文件,添加并提交了该文件;
    做了git remote add second file:///D:/path/to/reposgit push second master

但得到以下信息:

Counting objects: 3, done.
Writing objects: 100% (3/3), 218 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
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 file:///D:/path/to/repos/repo2/
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'file:///D:/path/to/repos/repo2/'

0 个答案:

没有答案