1

I cloned a project over ssh, made some changes, commit it, and then trying to push changes back (by $> git push), but I'm getting an error: "remote: error: refusing to update checked out branch: refs/heads/master".

Why is that, and how to fix it?

1

3 Answers 3

6

You should only push to bare repositories

Sign up to request clarification or add additional context in comments.

Comments

0

There might be some changes applied to the remote branch after you checked it out. If you are talking about single commit you made, and remote branch is master, then do:

git fetch origin

to fetch most recent changes

git rebase origin/master

to put your changes on top, and finally

git push origin master

The last command can be reduced to the one you used, but it is usually a good habit to specify where exactly you push the changes on the current branch.

Comments

0

It seems like you've cloned a personal repository (where files are checked out etc.).

You can't push back to the currently checked out branch on the remote, which is origin/master in your case.

But you can create a new branch in your clone and push that one back.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.