TGViewer
Computer Science and Programming Computer Science and Programming @computer_science_and_programming ยท 140K subscribers
Post #1239 62.1K
๐—š๐—ถ๐˜ ๐— ๐—ฒ๐—ฟ๐—ด๐—ฒ ๐˜ƒ๐˜€ ๐—ฅ๐—ฒ๐—ฏ๐—ฎ๐˜€๐—ฒ

One of the most powerful Git features is branching. Yet, while working with it, we must integrate changes from one branch into another. The way how to do this can be different.

We have two ways to do it:

๐Ÿญ. ๐— ๐—ฒ๐—ฟ๐—ด๐—ฒ

When you merge Branch A into Branch B (with ๐š๐š’๐š ๐š–๐šŽ๐š›๐š๐šŽ), Git creates a new merge commit. This commit has two parents, one from each branch, symbolizing the confluence of histories. It's a non-destructive operation, preserving the exact history of your project, warts, and all. Merges are particularly useful in collaborative environments where maintaining the integrity and chronological order of changes is essential. Yet, merge commits can clutter the history, making it harder to follow specific lines of development.

๐Ÿฎ. ๐—ฅ๐—ฒ๐—ฏ๐—ฎ๐˜€๐—ฒ

When you rebase Branch A onto Branch B (with ๐š๐š’๐š ๐š›๐šŽ๐š‹๐šŠ๐šœ๐šŽ), you're essentially saying, "Let's pretend these changes from Branch A were made on top of the latest changes in Branch B." Rebase rewrites the project history by creating new commits for each commit in the original branch. This results in a much cleaner, straight-line history. Yet, it could be problematic if multiple people work on the same branch, as rebasing rewrites history, which can be challenging if others have pulled or pushed the original branch.

So, when to use them:

๐Ÿ”น ๐—จ๐˜€๐—ฒ ๐—บ๐—ฒ๐—ฟ๐—ด๐—ถ๐—ป๐—ด ๐˜๐—ผ ๐—ฝ๐—ฟ๐—ฒ๐˜€๐—ฒ๐—ฟ๐˜ƒ๐—ฒ ๐˜๐—ต๐—ฒ ๐—ฐ๐—ผ๐—บ๐—ฝ๐—น๐—ฒ๐˜๐—ฒ ๐—ต๐—ถ๐˜€๐˜๐—ผ๐—ฟ๐˜†, especially on shared branches or for collaborative work. It's ideal for feature branches to merge into a main or develop branch.

๐Ÿ”น ๐—จ๐˜€๐—ฒ ๐—ฟ๐—ฒ๐—ฏ๐—ฎ๐˜€๐—ถ๐—ป๐—ด ๐—ณ๐—ผ๐—ฟ ๐—ฝ๐—ฒ๐—ฟ๐˜€๐—ผ๐—ป๐—ฎ๐—น ๐—ฏ๐—ฟ๐—ฎ๐—ป๐—ฐ๐—ต๐—ฒ๐˜€ or when you want a clean, linear history for easier tracking of changes. Remember to rebase locally and avoid pushing rebased branches to shared repositories. Also, be aware ๐—ป๐—ผ๐˜ ๐˜๐—ผ ๐—ฟ๐—ฒ๐—ฏ๐—ฎ๐˜€๐—ฒ ๐—ฝ๐˜‚๐—ฏ๐—น๐—ถ๐—ฐ ๐—ต๐—ถ๐˜€๐˜๐—ผ๐—ฟ๐˜†. If your branch is shared with others, rebasing can rewrite history in a way that is disruptive and confusing to your collaborators.
  • ๐Ÿ‘ 103
  • โค 2
More from @computer_science_and_programming
  1. Oct 18, 2026Claude Enterprise, now available self-serve Claude Enterprise is now available for self-seโ€ฆ
  2. Oct 8, 2026Dark mode toggles: two states are enough โ€ข Lea Verou (Light, Dark, System). The core argumโ€ฆ
  3. Oct 3, 2026BYD says it will have a solid-state car next year, the earliest date anyone has given BYDโ€ฆ
  4. Oct 1, 2026Introducing G#: A Go-like language for .NET G# is a new open-source, Go-inspired programmiโ€ฆ
  5. Sep 30, 2026Chrome for Developers Chrome 146 introduces three notable features for web developers. Scrโ€ฆ
  6. Sep 26, 2026Introduction to Solon A comprehensive tutorial walks through building a REST API with Soloโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’