Git push to master failed ...
I'm not sure where to look since the list of errors until the bottom. But usually this is what I did.
What I've done:
git clone url .
git add abc.txt
git commit -m "testing"
git push origin master / git push
Mistake:
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 ../git_abc/
source to share
You push master
from your clone to the original repo where the original repo itself has master
and the original repo is not a repo bare
. GIT
doesn't allow it.
To achieve what you are trying to do,
Either use an initial staging repo that you push to and then fetch from that repo.
git clone --bare <origin/repo> intermediate
In the original local repo
git remote add upstream <path/to/intermediate>
git push upstream master
In your original repo
git remote add downstream <path/to/intermediate>
git pull downstream master
Or push to some other branch in the source repo and merge that branch into the master branch in the source repo.
From local repo
git push origin master:master_to_be_merged
In the original repo
git checkout master
git merge master_to_be_merged
Or ignore these warnings and press anyway
In this case, you will have to take extra care to ensure that nothing breaks, and this is not recommended anyway.
At the beginning of the repo, enter
git config receive.denyCurrentBranch ignore
And now from your local clone do
git push origin master
source to share