nukl
nukl

Reputation: 10531

Problem with git push

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?

Upvotes: 1

Views: 4966

Answers (3)

matthias.lukaszek
matthias.lukaszek

Reputation: 2220

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.

Upvotes: 0

Ruslan Kabalin
Ruslan Kabalin

Reputation: 6908

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.

Upvotes: 0

Related Questions