I'm a coder who has worn a lot of hats, from individual contributor to lead engineer to "CTO" (yes, in quotes, make of that what you will!). I've a lot to learn and hopefully some to share as well.
git fetch && git rebase origin/main && git push --force
This is basically what I do to "merge" from main into a dev branch. But I find the results are usually much better than using git merge. Easier conflict resolution process and clean commit history. But as always when rebasing and force-pushing, you have to consider the pain it may cause to others working in the same branch (but if it's just you - go for it!)
Don't use the --force flag, even in that situation. Use --force-with-lease for the rare case where you do end up with a remote change during the rebase.
git fetch && git rebase origin/main && git push --force
This is basically what I do to "merge" from main into a dev branch. But I find the results are usually much better than using
git merge
. Easier conflict resolution process and clean commit history. But as always when rebasing and force-pushing, you have to consider the pain it may cause to others working in the same branch (but if it's just you - go for it!)Don't use the
--force
flag, even in that situation. Use--force-with-lease
for the rare case where you do end up with a remote change during the rebase.That should be named --nudge
Or change to --force --force when you really mean it.
Yes
Right
Thanks for sharing
You are absolutely right.
We should avoid using force.
But thanks for your suggestions 👍