user1414745
user1414745

Reputation: 1317

git rebase local branch on origin/master

I have problems with git:

let's say there was a commit c1 on origin/master 1. I made a branch "local-work", committed and pushed the branch to origin.

c1 <- origin/master
c1 <- c2 <- origin/local-work
c1 <- c2 <- local-work

So far so good. The idea was to work further in this branch and push my work to origin. But I also want to always have the newest from origin/master. So, I committed again:

c1 <- c2 <- c3 <- local-work

Then, my colleagues pushed their work:

c1 <- c4 <- origin/master

This is where I wanted to get their work into my local-work branch before pushing the branch to the server. So I did rebase:

c1 <- c4 <- c2 <- c3 <- local-work.

Now I tried to push my work to origin/local-work and it was rejected. How can I fix the situation?

Thank in advance for any suggestions!

Upvotes: 1

Views: 740

Answers (1)

Paul Draper
Paul Draper

Reputation: 83205

It was rejected because rebasing changed your commits.

If only you have worked on local-work, force the push (which overwrites the remote branch)

git push -f origin local-work

If others have worked on local-work, you should have merged instead of rebasing.

Upvotes: 2

Related Questions