sdlins
sdlins

Reputation: 2295

Rebasing between tagged versions removing other commits on Git

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.

Upvotes: 1

Views: 485

Answers (1)

CharlesB
CharlesB

Reputation: 90336

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.

Upvotes: 2

Related Questions