Skip to content

Instantly share code, notes, and snippets.

@gidhon
Last active December 5, 2023 11:17
Show Gist options
  • Select an option

  • Save gidhon/3e38fdbf681adb7199a1 to your computer and use it in GitHub Desktop.

Select an option

Save gidhon/3e38fdbf681adb7199a1 to your computer and use it in GitHub Desktop.

Revisions

  1. Gideon Kreitzer revised this gist Aug 13, 2014. 1 changed file with 1 addition and 9 deletions.
    10 changes: 1 addition & 9 deletions git_commit_reset.md
    Original file line number Diff line number Diff line change
    @@ -18,12 +18,4 @@ You have made some commits, pushed it upstream to the remote branch, then realiz
    7. this will merge all the changes from the old branch into the new one while ignoring the commit history
    8. do a status update to see what's cooking
    - `git status`
    9. you may now re-stash/add, starting with a clean slate

    then switch to master and create a new branch:
git checkout master
git pull origin master
    git checkout -b google_glass_squash
    then make sure you're in the new branch:
git checkout google_glass_squash
    then merge in your changes in your google glass branch into your new branch:
git merge google_glass_squash --squash
    um hang on
    sorry that last one should be:
git merge google_glass --squash
    which will merge all your changes in google_glass into your new google_glass_squash branch, and ignore the history
    9. you may now re-stash/add, starting with a clean slate
  2. Gideon Kreitzer renamed this gist Aug 13, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion reset.md → git_commit_reset.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ Discard commits while saving changes
    =

    ## Scenario
    You have made some commits, pushed it upstream to the remote branch, then realized that some or all of those commits must for some reason not be included. In example, accidently commiting large multimedia files that will forever bloat the commit history of the branch.
    You have made some commits, pushed it upstream to the remote branch, then realized that some or all of those commits must for some reason not be included. In example, accidently commiting large multimedia files (blobs) that will forever bloat the commit history of the branch.

    1. ensure all changes are commited in your current, "faulty" branch
    2. switch to your master branch
  3. Gideon Kreitzer created this gist Aug 13, 2014.
    29 changes: 29 additions & 0 deletions reset.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    Discard commits while saving changes
    =

    ## Scenario
    You have made some commits, pushed it upstream to the remote branch, then realized that some or all of those commits must for some reason not be included. In example, accidently commiting large multimedia files that will forever bloat the commit history of the branch.

    1. ensure all changes are commited in your current, "faulty" branch
    2. switch to your master branch
    - `git checkout master`
    3. update master with latest changes on remote
    - `git pull origin master`
    4. create a new branch and check in to it
    - `git checkout -b <new-branch-name-squash>`
    5. ensure you're in the new branch
    - `git branch`
    6. merge changes from "faulty" old branch into this new branch
    - `git merge <old-faulty-branch> --squash`
    7. this will merge all the changes from the old branch into the new one while ignoring the commit history
    8. do a status update to see what's cooking
    - `git status`
    9. you may now re-stash/add, starting with a clean slate

    then switch to master and create a new branch:
git checkout master
git pull origin master
    git checkout -b google_glass_squash
    then make sure you're in the new branch:
git checkout google_glass_squash
    then merge in your changes in your google glass branch into your new branch:
git merge google_glass_squash --squash
    um hang on
    sorry that last one should be:
git merge google_glass --squash
    which will merge all your changes in google_glass into your new google_glass_squash branch, and ignore the history