How can i remove detached commits from git?

I have two detached commits. How can i remove they as if they had never been?
I don’t want save history or another logs. Nothing.

  • Turning off the pager in git for the stash command only
  • git doesn't seem to pull all updates - HEAD and origin/HEAD in different positions
  • How do I set up git in deploy.rb in a rails 4 app using mina?
  • Git bare - what to backup?
  • Aborting commit due to empty commit message
  • Xcode 6.0.1 crashes when merging 2 branches
  • Use 'git filter-branch' to correct committer dates in last N commits?
  • How to import existing Git repository into another?
  • Getting the information of squashed commits in Git
  • Forking only a specific branch from Github repository
  • git svn clone > git svn rebase > Unable to determine upstream SVN information from working tree history
  • efficiently rewriting (rebase -i) a lot of history with git
  • One Solution collect form web for “How can i remove detached commits from git?”

    Do you mean commits made while you had a detached HEAD? If so, just:

    git checkout some_branch

    Your commits will no longer be visible in e.g. git log. They will be culled from storage at some point while Git runs its garbage-collection sweeps. If you want to cull things now, see answers to this question: How to remove unreferenced blobs from my git repo.

    Git Baby is a git and github fan, let's start git clone.