I have a Git 'git1' repository that has about 35,000 commits. I need to create a new repository 'git2' that contains the last 1,000 commits of git1, is there any way to do this ??
Thanks in advance.
I have a Git 'git1' repository that has about 35,000 commits. I need to create a new repository 'git2' that contains the last 1,000 commits of git1, is there any way to do this ??
Thanks in advance.
I've done it a couple of times following what it says this article .
First clones repo git1
. Then you change the remote to point to git2
.
Identify the sha
of the commit that will be your original new commit. In your case the one that is 1000 commits behind HEAD
$ git rev-parse HEAD~1000
e41d7f633c45c46bd42e97cecf93204191d9e4c9
It tells you that the sha
of your new root will be e41d7f633c45c46bd42e97cecf93204191d9e4c9
but by love we will tell you e41d7f633
.
git checkout --orphan temp e41d7f633
git commit -m "Nuevo primer commit"
git rebase --onto temp e41d7f633 master
And then pusheas a git2
.
Note that the sha
from your first commit to the present will have changed rebase product.