Pushing files on one git-branch
I have a website on a server and I want to begin sharing my work and so I am working with git. I am very new to it.
So on the remote server, I made a “git init” and a git commit to move all the work on the .git directory (always on the remote server).
Then I made a git clone (with an ssh connection) on my local server. And then I changed some files and committed it (worked fine) and then pushed it, but here is the error message :
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 ssh://email@example.com/homez.501/sameditr/www/.git ! [remote rejected] master -> master (branch is currently checked out) error: failed to push some refs to 'ssh:...'
Does anybody has an idea ?
2 Solutions collect form web for “Pushing files on one git-branch”
If you meant to create central repository on remote server, you should create bare repository:
git init --bare
You can configure current non-bare repository to accept updates (the error message is even telling you how), but much simpler way is to delete current repo on a remote server and create the new, bare one.
Here’s a link to detailed explanation of difference between bare and non-bare repos.
I usually do the following:
on server, inside webapp directory
$ git init $ git add * $ git commit -a
to have at lease an Initial Commit
on dev computer, you may do:
$ git init $ git remote add origin git+ssh://server/var/www/.git/ $ git branch --set-upstream master origin/master $ git pull
edit files on dev
$ git push
Hope this helps!