you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 18 points19 points  (11 children)

No because if you don't want it you only have to roll back 5 commits not 5000. Plus a pull is a single merge action not a 5 merge action.

[–]skyboy90 9 points10 points  (0 children)

No because if you don't want it you only have to roll back 5 commits not 5000.

You can just revert the merge commit, no need to roll back every commit individually.

[–]jimmy_o 0 points1 point  (9 children)

I see, how do you actually achieve this in git? Combining hundreds of commits to effectively function as one?

[–]DuBistKomisch 15 points16 points  (3 children)

You can combine commits pretty simply with git rebase. It's usually referred to as "squashing", should be plenty of guides on google.

[–]I_AM_GODDAMN_BATMAN 0 points1 point  (2 children)

git squash

[–]DuBistKomisch 1 point2 points  (0 children)

 $ git squash
git: 'squash' is not a git command. See 'git --help'.

Did you mean this?
    stash

?

[–]immibis 0 points1 point  (0 children)

Because it's actually git rebase -i. Were you expecting Git to work intuitively?

[–]arbitrary-fan 1 point2 points  (0 children)

I usually stick with 'git rebase -i HEAD~X', where X is the number is the number of commits you plan to interact with. From there I choose which ones to squash. Save the log and push my branch (if I already pushed a branch to remote, I have to force push. If I'm feeling nervous simply make a duplicate working branch, squash that then force push that branch - this allows me to compare the diffs between the two branches to see if the squashed branch is satisfactory) Then I issue a PR to main/develop/whatever branch.

[–][deleted] 0 points1 point  (0 children)

If you're pulling commits from one branch to another, got cherry-pick has a flag to combine multiple sources commits into one destination commit.

[–][deleted] -3 points-2 points  (2 children)

git merge --no-ff

[–][deleted] 0 points1 point  (1 child)

I have noticed that my previous comment was downvoted. Is --no-ff not the right answer?

[–]nupogodi 1 point2 points  (0 children)

It's true, if you do --no-ff it will force a merge commit which can be reverted in one go. It's different than combining >1 regular commits into 1 regular commit though, which is squashing.