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 trial

Development Tools Git Basics Working With Remote Repositories Pushing and Pulling

error while trying to push

Counting objects: 3, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 315 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 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 /Users/hadifarhat/Github/grepo1 ! [remote rejected] master -> master (branch is currently checked out) error: failed to push some refs to '/Users/hadifarhat/Github/grepo1'

2 Answers

I 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.

Raymond James Cabrera
PLUS
Raymond James Cabrera
Courses Plus Student 7,022 Points

You also have to make sure you're on different branches between the two repositories. Git uses it as a defense mechanism to make sure you don't screw anything up between the two. That's why he went back to the 'master' branch in the original repo.