Spencer Sharkey Spencer Sharkey - 7 days ago 4
Git Question

Copy commit history from previous repo into new repo

We have a git repository we have been using over a span of two years to track a long-term project. Recently we moved most of our current and new projects from GitHub to a private gitlab installation. Unfortunately we didn't move this specific project, and a few weeks of work have gone into the new repository.

Mind you, the repository's starting point is the same file structure as the last commit of the old GitHub repo, so basically we want to copy the commit history from the GitHub repository into our already-started repo.

As I'm trying to visualize this for you, here is a screenshot of the git log of our new repository:

New Repo Git Log


Master commit
is an addition of all the files from the latest commit in the old github repo:

Old GitHub Repo

The date of the commits will not conflict as some time has passed since work has been done.


Pull the original project into a new branch in the new repo, then cherry-pick the commits in the new repo's existing branch (except the original commit) onto the new branch.

This will create a separate branch with the history you want. Review the new history, then push it (-f) over the existing remote.