I am creating a new pristine repository for the next generation of our product. I need to use some "state" from the old repo -- similar to cherry-picking. In fact, functionally it would be simply resetting to a commit on the old repo then committing the file changes to the new repository. I did find that I could checkout the old branch, reset --soft to the earliest commit, then commit those files. But it seems like a hack. Since I see upstream and origin as a bit of a pattern, it seems like this would not be too uncommon, although I guess most of those cases would want commits.
You need to do a checkout --orphan so that you go to that revision (working tree content) but have no history behind it. When you do your first commit, it will be a root commit, no history behind it.
git checkout ---orphan -b new-branch some-revision-to-get-working-tree
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.