I have a Git repository whose oldest commit is version 6.8.2 (it is tagged “v6.8.2”). I have version 6.8.1 of the package that I would like to commit to the repository as the parent commit of the oldest commit. Is this possible? If so, how?
Share
You could rebase your current branch on top of the oldest commit that you want (v6.8.1). It will rewrite your history, though, but it is possible.
Edited to add more
Assuming your code is on the branch
masterClear out the existing code and create a new branch. Your old code is not lost – it still exists on the master branch.
Now you are on the branch
newbasewhich is an empty directory. Add the files that you want to be the new base to here.New you have two branches
masterwhich has your original code andnewbasewhich has only your new base.Now checkout the
masterbranch and rebase it upon thenewbasebranchAnd then All you need to do is fix the conflicts, and you have a new
masterbranch that starts at the earlier state of the code.This is all a bit of a mess though. If you just want to add the code to the repository, just do the first bit, which creates a new branch. Tag it so that you know what it is, there is no need to rebase the
masterbranch on to it because if you get to the base of master, and want to go further back in time – you can just see what is in the other branch.