Skip to content

Instantly share code, notes, and snippets.

@charandas
Last active November 26, 2017 08:48
Show Gist options
  • Save charandas/3bb9c2ca4e869219d259 to your computer and use it in GitHub Desktop.
Save charandas/3bb9c2ca4e869219d259 to your computer and use it in GitHub Desktop.

Revisions

  1. charandas revised this gist Oct 29, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-truncate.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    git checkout <hash-where-you-want-to-clip-history>
    git checkout --orphan new-master
    git checkout new_master
    git cherry-pick first-commit-to-include^..last-commit-to-include`
    git cherry-pick first-commit-to-include^..last-commit-to-include

    # Prepare master backup
    git checkout master
  2. charandas revised this gist Oct 29, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-truncate.sh
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ git checkout -b master-backup
    git branch -D master
    git checkout new_master
    git checkout -b master
    git push --force origin master`
    git push --force origin master
    # Delete the new_master branch as task is done
    git branch -D new_master
  3. charandas revised this gist Oct 29, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion git-truncate.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # Prepare new_master
    git checkout <hash-where-you-want-to-clip-history>
    git checkout --orphan new-master`
    git checkout --orphan new-master
    git checkout new_master
    git cherry-pick first-commit-to-include^..last-commit-to-include`
  4. charandas created this gist Oct 29, 2015.
    22 changes: 22 additions & 0 deletions git-truncate.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    # Prepare new_master
    git checkout <hash-where-you-want-to-clip-history>
    git checkout --orphan new-master`
    git checkout new_master
    git cherry-pick first-commit-to-include^..last-commit-to-include`

    # Prepare master backup
    git checkout master
    git checkout -b master-backup

    # Replace master
    git branch -D master
    git checkout new_master
    git checkout -b master
    git push --force origin master`
    # Delete the new_master branch as task is done
    git branch -D new_master
    # READ CAREFULLY, delete the master backup if sure that the task completed successfully
    git branch -D master-backup