Skip to content
Snippets Groups Projects

Reset commits before given Hash

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Leon Schmidt
    Edited
    reset.sh 303 B
    COMMIT_HASH=your_hash_here
    
    git filter-branch --parent-filter '
        read parent
        if [ "$parent" = "-p ${COMMIT_HASH}" ]
        then
            echo
        else
            echo "$parent"
        fi'
    
    git update-ref -d refs/original/refs/heads/master
    git reflog expire --expire-unreachable=all --all
    git gc --prune=all
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment