DEV Community

Discussion on: Git Concepts I Wish I Knew Years Ago

Collapse
 
bloodgain profile image
Cliff

Never push -f unless you're the repo manager repairing some terrible mistake that will require everyone to re-clone the repository. I always set my upstream/shared repository to fast-forward pushes only. I call it the "No Jedi Rule" -- force pushing not allowed!

Collapse
 
bernardwiesner profile image
Bernard Wiesner

Personally I often push force just to keep my commits clean, otherwise have an ugly history like 'bug fix', 'another bug fix', especially when working on new features that require many changes. Also nice to rebase from parent branch to avoid having all the merge commits.

Of course only push force when working alone on your branch.

Collapse
 
bloodgain profile image
Cliff

Oh, definitely, when working alone, I break this rule all the time. It's really just part of the greater rule to never rewrite shared history. You can rewrite your own history all you want, though.

I think rebase is under-utilized, too. If I'm working directly on a shared branch, I almost never do a pull. I always fetch and rebase to keep the history clean. It actually does more than that, though, it keeps the first parent path consistent, which makes the log much easier to read and the graph much easier to trace. I'm also a fan of using rebase -i to squash feature branches into a single commit.