Remove / cut off Git's revision / commit history

后端 未结 4 412
难免孤独
难免孤独 2021-02-04 04:36

I have a project that contains traces to another project of myself that I\'ve used as a kind of a template project. Now I want to remove these traces entirely from the repositor

4条回答
  •  抹茶落季
    2021-02-04 05:05

    Was trying to follow @vergenzt answer but git started to apply patches from the 1st commit which was 3000+ commits before the one I needed to start from.

    My purpose was to make smaller repo for the new project that is based on current one. Unfortunately I needed some history to be preserved from current project (several months). This is how I finally managed to do it:

    Command line tool was not quite convenient to do this because you will need to resolve conflicts. Fortunately there is a Rebase feature in TortoiseGit where you need to provide 2 barnches: master (left) and temp (right). Then skip all commits before the one where your temp branch on including commit (select commits and use 'skip' in right click menu). After rebase started you will get some conflicts which you can resolve right in the rebase GUI. I always picked "use master branch version" in right click menu. This took much less time then bothering with CLI. After everything was done I've additionally copied all project files from latest version of original repository upon files in new repository (overwrite all) to make sure nothing lost. I've got only several files that were in .gitignore and somehow were not ignored. Other files were same.

    I hope this helps someone.

提交回复
热议问题