I've read that it's never recommended to re-base a branch which is made publicly available. But let's say I have master which everyone is working on and my_feature where only I am working on it (but is also pushed to a remote repo). Say I want to merge my_feature into master, so I checkout my_feature first, do git rebase master, then switch to master and do git merge my_feature.
Is this safe to do since many people have made plenty of commits and are heavily collaborating on the master branch (but almost nobody on the new_feature branch)?
Short answer: Yes it is safe. Long answer: Rebasing itself is only dangerously if you do it wrong.
Wrong: You rebase a branch (
origin/master) which was cloned by some people --> bad. In this case you are destroying the common history of 'some' people.Right: You rebase something onto
master, thats correct. But you must not forget to fetch theorigin/masterbranch from the origin first, and update yourmasterbranch to it. When your localmasterandorigin/masterbranch are the same, you can rebase your changes onto themaster.Then
pushthe changes so thatmasterandorigin/masterare the same again.See: Git pull.rebase this is a possibly dangerous operation