Reputation: 154
Sorry, this maybe a stupid question, but I just couldn't figure it out the problem.
I have cloned a branch via git (bitbucket), changed some files, commited these and pushed them back to the remote origin.
Now I want to push this commit to a different branch which is partly ahead and behind of the current branch. So I tried: git push origin HEAD:differentBranch
, but this didn't work ("Updates were rejected because a pushed branch tip is behind its remote counterpart").
How can I fix this? Sorry again, my skills in git are still developable.
Upvotes: 4
Views: 1999
Reputation: 4320
You can do that by using git cherry pick. So you can try like this:
git checkout differentBranch
git cherry-pick <commit # from previous commit from your first branch>
Upvotes: 7