0

I want to ask how I can clean the "WIP on" and "index on" entries from my git history. These are entries created by stashes which have already been dropped. The branch multiTE_loop_develop does not exist any longer. Ideally they would just disappear and after hash 864c002 follows 854a54c of course with the changes of the WIPs applied.

Thanks for your help. Git log

  • What do you mean they do not exist anymore? – Rafael Jun 13 '18 at 13:30
  • "WIP on multiTE_loop_develop" is in history and the current branch far more to the top is another one. The branch "multiTE_loop_develop" was deleted. I just want to make the history clean. –  Jun 13 '18 at 13:34
  • If you don't want to see WIP commits in your main history, you need to not commit them in your main history. If they're ancestors of your current branch head, there's there forever unless you rewrite history (which doesn't work well if you or your team have other remote clones) – Useless Jun 13 '18 at 13:36
  • Possible duplicate of [Flatten old history in Git](https://stackoverflow.com/questions/4506758/flatten-old-history-in-git) – Rafael Jun 13 '18 at 13:36
  • Those look to me like stash entries. You'd have to go out of your way to integrate a stash entry into your main history, so either you have someone in your repo doing something very weird, or this is a case of a tool generating ambiguous log output. If the WIP/Index entries aren't needed, try cleaning up stashes and see where that leaves you. – Mark Adelsberger Jun 13 '18 at 13:39
  • Yes, I'm new to git and unfortunately I applied some stash-commands and then dropped the stashes. Now these are WIP entries of former stashes. Maybe it is possible to transform these ugly entries into "normal" commit entries? –  Jun 13 '18 at 14:18

1 Answers1

1

If you want to re-write your git history you probably want to use the git rebase command. Do be careful with this though, if you've already pushed these changes to something like bitbucket or github you probably just have to leave it.

With rebase you can edit the commit messages, squash commits together, tear them apart, and all sorts. In this case you might want to re-word the messages or squash the commits together into a single commit. For this you'll want to use the interactive rebase.

You can follow the steps provided by Rob here: Git: Interactively rebase a range of commits which shows you how to run an interactive rebase on multiple commits. Once you've got a text editor open during the rebase you can then squash the various WIP commits together and reword their messages following the instructions printed into the editor.

If you have already pushed these changes to a public remote (github, gitlab, bitbucket, etc) you probably don't want to do this. Re-writing the git history will put you at odds with anyone else working from the remote git server, this will make things pretty nasty for your team mates to unpick. A general rule of thumb by most people is if you've pushed your changes to somewhere public, you shouldn't change the history even if the history ended up looking a bit ugly.

Elliot Blackburn
  • 3,759
  • 1
  • 23
  • 42