DEV Community

Discussion on: 20 Git Commands Every Developer Should Know

Collapse
 
mistval profile image
Randall

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!)

Collapse
 
fjones profile image
FJones

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.

Collapse
 
jessekphillips profile image
Jesse Phillips

That should be named --nudge

Or change to --force --force when you really mean it.

Thread Thread
 
krishnaagarwal profile image
Krishna Agarwal

Yes
Right
Thanks for sharing

Collapse
 
krishnaagarwal profile image
Krishna Agarwal

You are absolutely right.
We should avoid using force.

But thanks for your suggestions 👍