On my local PC, a have a repo (A) of a web project. On the same PC I have several deployments (B, C) of that project and sometimes it's more convenient to develop and test new features in those deployments.
I wonder how can I connect those deployments via git to use the same codebase (but create different branches). One way would be to use a common remote repo, push changes (from, say, A) there and pull those back to another local repo (B), but ideally I'd like to update those without access to the remote repo (by doing a git command like git push
or git pull
). Is this possible with git? Or do I have to install something like git service?
What I've tried to implement the suggestion by torek by the following steps:
- created 2 folders, "repo1" and "repo2" in a folder, let's call it "D:\path\to\repos"
- initialized git in both (
git init
) - in repo1, created a file, added and commited it;
didgit remote add second file:///D:/path/to/repos
andgit push second master
but got the following:
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/'