Skip to content

Commit e2a6c4d

Browse files
committed
Rebase vs. merge: FIGHT
1 parent c37043c commit e2a6c4d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

en/book/03-git-branching/chapter3.asc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,26 @@ But if you do, tell everyone who's working on that branch to `git pull --rebase`
777777

778778
==== Rebase vs. Merge
779779

780+
Now that you've seen rebasing and merging in action, you may be wondering which one is better.
781+
Before we can answer this, let's step back a bit and talk about what history means.
782+
783+
One point of view on this is that your repository's commit history is a record of what actually happened.
784+
It's a historical document, valuable in its own right, and shouldn't be tampered with.
785+
From this angle, changing the commit history is almost blasphemous; you're _lying_ about what actually transpired.
786+
So what if there was a messy series of merge commits?
787+
That's how it happened, and the repository should preserve that for posterity.
788+
789+
The opposing point of view is that the commit history is the story of how your project was made.
790+
You wouldn't publish the first draft of a book, and the manual for how to maintain your software deserves careful editing.
791+
This is the camp that uses tools like rebase and filter-branch when they are appropriate for telling the story in the way that's best for future readers.
792+
If that requires a force-push every now and then, so be it.
793+
794+
Now back to the question of which is better.
795+
Hopefully you'll see that it's not that simple.
796+
Git is a powerful tool, and allows you to do many things to and with your history, but every team and every project is different.
797+
Now that you know how both of these things work, it's up to you to decide which one is best for your particular situation.
798+
780799
=== Summary
781800

782801
We’ve covered basic branching and merging in Git. You should feel comfortable creating and switching to new branches, switching between branches and merging local branches together. You should also be able to share your branches by pushing them to a shared server, working with others on shared branches and rebasing your branches before they are shared.
802+
Next, we'll cover what you'll need to run your own Git repository-hosting server.

0 commit comments

Comments
 (0)