5.5. Rebasing to Rewrite History.md - shinokada/gitnotes GitHub Wiki

Rebasing to Rewrite History

Rebasing in this manner is best used for branches that you haven’t shared with anyone else.

❯ git log --oneline --graph

We are going to change the following:

* dc24e14 (HEAD -> wValidator) Updated team acronym to teamWYXZC
* 72c4e8f Added Chris as a new maintainer to README.md
* 4c5274c Refactoring the main check function
* f0f212f Removing TODO
* d642b89 check04: Checking diagonal sums
* 791744c util06: Adding a function to check diagonals
* 556b640 check03: Checking row and column sums
* 75a6d1f util05: Fixing comment indentation
* 72ec86a util04: Adding a function to check column sums
* 34a656c util03: Adding function to check row sums
* 0efbaf2 check02: Checking the array contains the correct values
* 136dc26 (origin/zValidator) Refactoring the range checking function
* 665575c util02: Adding function to check the range of values
* 0fc1a91 check01: checking that the 2D array is square
* 5ec1ccf util01: Adding the checkSqaure function
* 69670e7 Adding a new secret
* 417696d Adding our chosen build tools version number

to the following by squashing utilxx and order checkxx:

* f8d6e1b (HEAD -> wValidator) Added Chris to README and updated
team acronym
* ededa27 Refactoring the main check function
* 2670142 Removing TODO
* d0bdabb check04: Checking diagonal sums
* 4424300 check03: Checking row and column sums
* 5e087af check02: Checking the array contains the correct values
* 1cb3ad3 Creating utility functions for Magic Square validation
* 6adde96 check01: checking that the 2D array is square
* 69670e7 Adding a new secret

Execute the following to start the interactive rebase on top of that base commit:

❯ git rebase -i 69670e7
pick 5ec1ccf util01: Adding the checkSqaure function
pick 0fc1a91 check01: checking that the 2D array is square
pick 665575c util02: Adding function to check the range of values
pick 136dc26 Refactoring the range checking function
pick 0efbaf2 check02: Checking the array contains the correct values
pick 34a656c util03: Adding function to check row sums
pick 72ec86a util04: Adding a function to check column sums
pick 75a6d1f util05: Fixing comment indentation
pick 556b640 check03: Checking row and column sums
pick 791744c util06: Adding a function to check diagonals
pick d642b89 check04: Checking diagonal sums
pick f0f212f Removing TODO
pick 4c5274c Refactoring the main check function
pick 72c4e8f Added Chris as a new maintainer to README.md
pick dc24e14 Updated team acronym to teamWYXZC

# Rebase 69670e7..dc24e14 onto 69670e7 (15 commands)

Change the above to the following order by using vim dd and shift+p:

pick 0fc1a91 check01: checking that the 2D array is square
pick 5ec1ccf util01: Adding the checkSqaure function
pick 665575c util02: Adding function to check the range of values
pick 136dc26 Refactoring the range checking function
pick 34a656c util03: Adding function to check row sums
pick 72ec86a util04: Adding a function to check column sums
pick 75a6d1f util05: Fixing comment indentation
pick 791744c util06: Adding a function to check diagonals
pick 0efbaf2 check02: Checking the array contains the correct values
pick 556b640 check03: Checking row and column sums
pick d642b89 check04: Checking diagonal sums
pick f0f212f Removing TODO

Save it.

❯ git rebase -i 69670e7
hint: Waiting for your editor to close the
Successfully rebased and updated refs/heads/wValidator.

Check it with git log --oneline --graph:

* b6cbe87 (HEAD -> wValidator) Updated team acronym to teamWYXZC
* db0ce2e Added Chris as a new maintainer to README.md
* 4ef74dc Refactoring the main check function
* 6fe4514 Removing TODO
* d4263cd check04: Checking diagonal sums
* 24b1405 check03: Checking row and column sums
* 6478327 check02: Checking the array contains the correct values
* 49c5e03 util06: Adding a function to check diagonals
* 73caa08 util05: Fixing comment indentation
* e563982 util04: Adding a function to check column sums
* 8161780 util03: Adding function to check row sums
* df77f3c Refactoring the range checking function
* 9ac4de8 util02: Adding function to check the range of values
* c4ceec3 util01: Adding the checkSqaure function
* 9591573 check01: checking that the 2D array is square
* 69670e7 Adding a new secret

Every single commit from your rebase script has a new hash — because they are new commits.

Rewording commit messages

⚠️ **GitHub.com Fallback** ⚠️