Rebasing between tagged versions removing other commits on Git

折月煮酒 提交于 2020-01-05 07:13:56

问题


I have a project which I am working by myself (no team). I have tagged some commits like v0.0.1, v0.0.9...v0.9.1 and so on. Now, I would like to rebase them leaving only those version tagged commits, but I have two problems:

  1. When I do git rebase -i v0.0.1 (the first version, more than 2000 commits since then) I dont know how to show the tags inside the 'rebase screen', that is where I define squashs;
  2. Even if I was be able to see the tags inside the rebase screen it would be so time consuming to define squashings manually on 2 thousand of commits;

Is the correct approach to do it? Is there a way to achieve that faster?

Thank you so much.


回答1:


You can't get the tags in interactive rebase, simply because tags are meant to be immutable, and rebase is modifying history, thus a contradiction.

Interactive rebase isn't made neither for operating on thousands of commits, you have to cope with it by using advanced functions of your text editor.

Are you sure you want to squash all your untagged commits? Even if you don't see interest now, it can be a great help to keep history (think git blame when you want to know what commit introduced a change.

If you want to see tag history, you can just ask git log --tagged. You get history simplification without altering your repo's history, which is precious to your project.



来源:https://stackoverflow.com/questions/12681171/rebasing-between-tagged-versions-removing-other-commits-on-git

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!