I'm was working with submodules and couldn't get them to work, so I figured I'd just try something simple, that absolutely can't fail. It does. And the error message, to me sounds like someone saying: By default you can't push into a non-empty repository because we will screw up the repo and your working directory. I can't imagine what could be wrong
I ran this simple script to create two Repos. 'Main' with a single file, V, which contains 'Version 1', and Clone that is a clone of Main. It then changes V to be 'Version 2' and commits the change. It then tries to push it and it blows chunks with an error message from heck.
mkdir Main
cd Main
git init
echo Version 1 > V
git add V
git commit -m "Initial"
mkdir ../Clone
cd ../Clone
git clone ../Main .
echo Version 2 > V
git commit -m "V2" -a
git push
Output is:
Initialized empty Git repository in /private/tmp/T/X/Main/.git/
[master (root-commit) a94775b] Initial
1 file changed, 1 insertion(+)
create mode 100644 V
Cloning into '.'...
done.
[master 385cf21] V2
1 file changed, 1 insertion(+), 1 deletion(-)
Counting objects: 5, done.
Writing objects: 100% (3/3), 237 bytes, 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: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To /tmp/T/X/Clone/../Main
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '/tmp/T/X/Clone/../Main'
Seriously? Updating the current branch is denied? Riiggghhht... And what exactly is the point of version control?
I realize that git is used by people, and some people think it is good enough to even promote. So, clearly the entire way I'm doing something must be wrong, but I can't for the life of me see what could be wrong with this.
Everything I do doesn't work like I would expect.