Posts

Showing posts with the label Version Control

Git Rebase: A Straight Line Instead of a Merge Commit

A feature branch starts clean. It branches off main on Monday, adds tax to the receipt total, and by Wednesday main has moved on: someone rounded the totals to two decimals and added a README. The branch still works, but merging it back adds a merge commit that joins two lines of history, a fork and a join for work that could read as a straight line. Rebasing is the other way to bring a branch up to date. It lifts the branch's commits off the old base and replays them on top of the latest main, so the history reads top to bottom. The question is when that straight line is worth the rewriting it takes. Quick answer Yes, rebase a branch only while it is yours alone, and merge once anyone else depends on it, because rebase lifts the branch's commits off the old base and replays them on top of the latest main. The feature branch added 17 percent tax while main rounded the totals, and after the rebase the tax commit sits on top of both main commits with no fork and no merge commit...

Git Branching Explained: Work Without Breaking the Main Code

Two people are working on the same small shop page. One changes the greeting, the other changes the shop total, and both save at the same time. Without branches, one overwrites the other, and the team spends the afternoon arguing about whose version was right. With branches, each person works on their own copy, Git keeps track of both, and the two changes are combined only when someone has looked at the result. A branch is that separate copy: a line of work that starts from the main code, moves on its own, and merges back only when it is ready. The main branch holds the code that works, and everything unfinished stays out of it until it is done. Quick answer A Git branch is a separate line of work that starts from the main code, moves on its own, and merges back only when it is ready. Use a branch for every change, even a small one, keep it short, keep main working, and let a review happen before the merge. That way two people can change the same project at the same time without overw...