Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Mozilla Hacks 15 min read How-to mediumAdept

Merging two GitHub repositories without losing commit history

MDN merged small example repositories into a larger parent repo while keeping full commit history, using only plain git commands. First, inside the source repo, all files move into a subdirectory matching the target layout (using zsh extendedglob negation like `mv ^(sw-test|service-worker)`, with hidden files moved separately so `.git` stays put). That change is merged, then the source is added as a remote in the target and merged with `git merge --allow-unrelated-histories`, resolving add/add conflicts such as README.md.

Assumes: Git basicsshell commands

Related posts

  • WebKit on GitHub!

    WebKit easyNovice

    WebKit froze its Subversion tree on June 23rd and moved source control to git hosted on GitHub, citing git's distributed collaboration model, its author/committer model, cheap branch and revert operations, and the fact that most contributors already worked from git-svn mirrors. GitHub was chosen for its developer community and an API that made pre- and post-commit automation easy to build. Because git hashes are unordered, which complicates bisection under WebKit's zero-tolerance performance regression policy, the project uses "commit identifiers": the ancestor count on main (git rev-list --count) plus a branch-relative count for branches. These identifiers are supported by the git-webkit script and the commits.webkit.org translation service.

  • Git Organized: A Better Git Flow

    Render mediumAdept

    Commit-as-you-go branches often produce commits mixing unrelated or half-finished changes, which makes reverts risky and pull requests tedious to review. A cleaner flow is to do the work first with throwaway WIP commits, then `git reset` back to the branch point (keeping the working tree), and rebuild logically grouped commits using `git add -p` for partial files. Verify that each new commit works on its own by stashing the remaining changes and testing, and use `git commit --amend` to fix up omissions. If anything goes wrong, `git reflog` can recover the original commits.

  • Sapling: Source control that’s user-friendly and scalable

    Meta Engineering easyNovice

    Meta has open-sourced the client for Sapling, a Git-compatible source control system built over 10 years that scales to repositories with tens of millions of files, commits and branches. Its UX centers on smartlog (a filtered view of your relevant commits), extensive undo/recovery commands, and first-class commit stacks backed by tracked mutation history, plus ReviewStack, a demo UI for reviewing GitHub PRs commit by commit. For scale, Segmented Changelog downloads only the commit graph's shape and lazily fetches data, answering ancestry queries in O(number-of-merges) and file history in O(log n). Sparse profiles committed to the repo, Watchman integration, and a forthcoming virtual file system and Rust server handle the working copy.

  • Native Git support in Zed

    Zed easyNovice

    Zed v0.177 adds native Git support built around speed, Git-native semantics and keyboard-first workflows: a Git Panel for staging and restoring, cmd-enter commits with optional LLM-written messages and automatic Co-Authored-By lines, a hunk-level Diff View like `git add -p`, and fetch/pull/push from the command palette. Under the hood, the text buffer was rebuilt so deleted hunks are part of the editor's coordinate system rather than rendered blocks, enabling search and selection inside them. Staged and unstaged hunks are interleaved by computing a "diff-of-diffs" (buffer vs HEAD compared with index vs HEAD), so focus isn't lost when staging. Conflict resolution, line-level staging and history visualization are planned next.

  • Optimizing Git’s Merge Machinery, #3

    Palantir hardMaster

    Git's merge machinery can skip rename detection for source files whose renames cannot change the merge result: files unmodified on the unrenamed side of history, and files not needed for directory rename detection's majority rule. Exploiting this meant pushing three-commit merge context across the old diff/rename-detection abstraction boundary, which only knew about two trees. For a typical cherry-pick touching ~10 files against 5K upstream renames, the comparison matrix shrinks from 5K×5K to ~10×5K. The mega-renames testcase drops from 130s to 11.4s on top of basename-guided detection, or from 1800s to 16s alone. The change ships in git 2.32.

The quest for software engineering knowledge.

Look:
Layout: