Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialUnsubscribed User
8,841 PointsGit PUSH Error - Help needed to resolve.
Hi,
i saw similar error faced by many people while pushing the changes to the remote repository. I tried it out but did not work.
Things which i did :
- Cloned the repository ~/my_clone_repo from remote repository ~/my_new_repo/
- Issued the command "git add" for the remote repository ~/my_new_repo for the connection.
- Performed changes in ~/my_clone_repo master branch.
- issued the command $ git push origin master and received the below error
Also in the tutorial, they performed the changes in the cloned repository by creating a branch. I did not create a branch here and edited the master directly.
Aisswarya@Aishu MINGW64 ~/my_clone_repo (master)
$ git push origin master
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 393 bytes | 0 bytes/s, done.
Total 3 (delta 1), 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 inconsist
ent
remote: error: with what you pushed, and will require 'git reset --hard' to matc
h
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 C:/Users/Aisswarya/my_new_repo
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'C:/Users/Aisswarya/my_new_repo'
1 Answer
Polina Zapreyeva
1,503 PointsI found a way to solve this issue. I went to cloned repository and run: git config --bool core.bare true
After that I went back to origin repository and pushed to cloned repository and it worked.