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 trialJames Izzard
10,797 PointsUnable to Push Changes to Remote - Error Message
Hi all, I am struggling to push changes from a one repository to another on the local machine. I have setup my test scenario as follows:
- Created a git project called 'git-testing' and initialised the git repository.
- Added a blank file 'index.html' and committed it.
- Cloned the repository to a sibling project folder called 'git-testing-clone'
- Setup 'git-testing-clone' as a remote repository to 'git-testing' called 'clone'
- Confirmed the remote has been setup by using 'git ls-remote clone'
- Made changes to 'index.html' inside 'git-testing'
- Commit my changes inside 'git-testing'
Now when I try to push my changes to clone, by doing the following:
git push clone master
I get the following error: C:\Users\James\Dropbox\WEB\git-testing>git push clone master Counting objects: 3, done. Delta compression using up to 8 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 334 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: 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-testing-clone ! [remote rejected] master -> master (branch is currently checked out) error: failed to push some refs to '../git-testing-clone'
I have done some Googling but I am struggling to understand the responses people are giving. Would be great if somebody could help me understand what may be going wrong.
Additionally, I have installed GIT to work inside the Windows console as I had some difficulties with backspace misbehaving inside the MINGW64 console that seems to come as default.
Many Thanks
1 Answer
marct
5,323 PointsI was getting the same error when trying to do a git push. I found that I needed to switch which repository I had checked out. I did git checkout master. Git told me your branch is ahead of origin/master by 1 commit. I was then able to do git push origin new_feature. It finished successfully telling me: To/home/treehouse/my_really_cool_project
- [new branch] new_feature -> new_feature
hope that helps others seeing this error.