Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am in a situation where I am trying to convert an open source project to Git, and I have recently gained access to historical data for the project. I have already made modifications to the repo, though, so I want to add these early changes as git commits to the beginning of the tree of commits in Git. (Yes, I am aware that this will change the SHAs for later commits; this is acceptable.) The data is provided as successive snapshots of the working directory. I want to set it up so that the state of the working directory for the later commits is not affected (I don't want to merge the changes in).

For example, if initial commit B adds files a and b to the working directory, and my historical commit A adds file a, I want to make a new commit B' parented from A that adds file b only. In both B and B', the working directory looks the same, and any subsequent commits on top of B can be safely rebased onto B'.

Is it possible to do this in Git? If so, how?

Edit: Note that I need to modify the initial commit. The standard usage of git commit appends a new commit as a child of the HEAD commit, and so does not work for the initial commit, which has no parent.

share|improve this question
up vote 3 down vote accepted

Something like this should work.

# Create a new branch with the old history
$ git checkout --orphan old-history    
$ git add <old-files>
$ git commit

# Rebase master on top of the branch with old-history
$ git checkout master
$ git pull --rebase . old-history
share|improve this answer

Im not sure if its possible to just do:

git add [files]
git commit -m 'first commit'

Then merge changes

git add [files]
git commit -m 'second commit'


git push

If this doesnt work then i think there is no way of achieving that.

share|improve this answer
Of course you can do this, but it will add the old commits to the end of the tree, not the start. – Mario Carneiro Aug 3 '13 at 3:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.