2

I need to get rid of commits that I have already reseted and force pushed to origin; they keep coming up whenever I pull or clone the remote repo.

I pushed commits to Pantheon's DEV environment, deployed on both TEST and LIVE environments. Later I did a hard reset to a certain commit and forced pushed to origin. Fast forward, when I cloned the repo again, I can still see the commits that I thought I had erased from history.

I can't see them in terminal with git log but I like to use GitKraken to visually see my git history, and there they appear all the time. I tried to wipe the local repo because thought it was simply a local thing— on Pantheon's DEV environment they are gone after the force push.

Nothings seems to solve this for me. Please help! My OCD is preventing me to ignore it and continue to do work and keep adding commits. I need my history to only show the commit where HEAD is currently at, and commits ahead of that to be gone from sight.

This is how it looks like when I open the repo using GitKraken ——» Screen Shot

Byron
  • 63
  • 6

1 Answers1

0

Git keeps track of all commits ever made in its database (inside the .git folder) until they are eventually garbage collected when no longer used. Visual tools like GitKraken usually show all commits reachable via a named branch or tag, regardless of whether the branch or tag is local or from a known remote repository.

What you probably want to do is delete the branches or tags that are linked to those commits you're no longer interested in. This will cause them to no longer be displayed in graphical tools, although they will remain in your .git database until GC'ed (this is generally what you want: avoids the visual distractions you're encountering, but keeps the data should you ever need to recover it).

To delete branches, take a look at this post on branch deletion. Syntax for deleting tags is the same, but you can check out this post if you want tag-specific examples.

aryzing
  • 4,982
  • 7
  • 39
  • 42
  • I am still a git-noob, and this is enlightening. Thanks for your response! Just tried `git push origin :refs/tags/pantheon_live_13` and got this error message `remote: PANTHEON ERROR: Tag removal rejected. The tag "pantheon_live_13" is a deployment tag and therefore cannot be deleted.` `You should push a new deployment tag instead.` `error: hook declined to update refs/tags/pantheon_live_13` Thought it was due to deleting a _live_ tag, but got the same error message when I tried with: `git push origin :refs/tags/pantheon_test_30` – Byron May 05 '19 at 04:12
  • I believe that's something you need to sort out with your git hosting service. As far as git is concerned, you now have the tools to achieve what you want. – aryzing May 05 '19 at 12:17
  • @Byron That rejection is coming from a Git hook created by your Git hosting service. It is not a Git restriction, it is a restriction put in place by your host.. – Daniel Mann May 05 '19 at 16:43
  • Thank you both, aryzing + @DanielMann! I contacted Pantheon's support team, and yes, apparently it's "platform designed" that tags cannot be deleted. I'm sure I'm not alone (at least I hope), so let me be vulnerable on behalf of others looking for a "way out". My question now is: How can I make it so that those commits are not just hanging (drive.google.com/file/d/1FAMZGG7BxfPMnz2-1q3pkLNv07iu-evU/view)? I have moved HEAD to the last commit, how can I get the other two, in blue, to "get in line"? – Byron May 05 '19 at 18:35