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

How do I push changes to a cloned git repo?

I am setting up a local dev environment, and I've cloned a repo. Every time that I try to push my changes from my dev environment to the remote repo, I get the following error:

Counting objects: 3, done. Delta compression using up to 8 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 378 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 git@192.168.1.3:/var/www/temp.ll.com ! [remote rejected] master -> master (branch is currently checked out) error: failed to push some refs to 'git@192.168.1.3:/var/www/temp.ll.com'

Is this a permissions issue on my remote repo? Is it a configuration issue on my local dev environment?

1 Answer

Bruce Röttgers
Bruce Röttgers
18,211 Points

Hey,

it seems like it's a problem with your local config. I would try the things out the error message suggests.

PS: Please format the output right using the three pack ticks (refer to the Markdown Cheatsheet for more information)

Bruce,

After fighting with this issue for a bit longer, I learned that git doesn't like to push changes from a cloned repo directly to the master branch of the origin repo. Instead, I had to create a new branch on my cloned local repo from which to push my changes first. Once I did that, I could push my changes to the corresponding branch on the origin repo.

Thanks for your help.