开发者

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开发者_如何学JAVA), 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?


You should only push to bare repositories


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜