DEV Community

Discussion on: Rewrite your git history in 4 friendly commands

Collapse
 
jmfayard profile image
Jean-Michel πŸ•΅πŸ»β€β™‚οΈ Fayard • Edited

Souvenir souvenir, this was my first article on this website actually :) dev.to/jmfayard/pull-requests-a-si...

git reset --soft is still my go-to solution, there is so much less opportunity to shoot yourself in the foot than git rebase --shit (not an actual git flag).

In practice, I almost always do that against origin/main to clean up the pull request

In this case, the complete workflow would be this:

git fetch
git merge origin/main

# if conflicts
echo "resolve conflicts in your IDE"
git commit -a -m "resolve conflicts"
# end if

git reset --soft origin/main
git commit -a -m "my commit message"
git push --force
Enter fullscreen mode Exit fullscreen mode

That's it, the PR contains only one commit my commit message and the workflow is pretty much idiot proof.

Collapse
 
whitep4nth3r profile image
Salma Alam-Naylor

Oh, nice!

I’m getting a lot of people all over the place say β€œwhy not rebase?” πŸ˜… and the fact of the matter is this method is less scary and much more suited to my usual use cases. As you say, you’re much less likely to shoot yourself in the foot β€” meaning you won’t end up on a weird state of β€œin an interactive rebase and not know how to get out if you make a mistake”.

Collapse
 
jmfayard profile image
Jean-Michel πŸ•΅πŸ»β€β™‚οΈ Fayard • Edited

It's a difference in mindset.

Some people like powerful tools like can do everything. If something go wrong they will read the reference docs and the best practices and make sure they get it right the next time.

For me the most important feature is simplicity, which for practical purpose I would define as focusing on choosing good enough solutions that minimize the probability that things could go wrong.

The first set will always prefer git rebase and the second git reset --soft

Thread Thread
 
whitep4nth3r profile image
Salma Alam-Naylor

Absolutely! Well said!