forked from eficode-academy/git-katas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Rebase-Exec] exercise more intuitive eficode-academy#242
- Loading branch information
1 parent
cd8f373
commit 944ebd4
Showing
5 changed files
with
22 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,16 +6,23 @@ | |
|
||
## Task | ||
|
||
Doing local development we've created a bunch of commits. We would like to deliver them all to master. We would also like all commits to pass our tests. | ||
|
||
Our test suite is contained in `test.sh`. We can use `git rebase --exec` to run the test suite for all commits. We have tagged the first commit in our history with `initial-commit`. | ||
|
||
1. Run the test script using `./test.sh` to see the most recent commit succeed | ||
1. Use `git rebase -i --exec ./test.sh initial-commit` to run the test script on all commits. You will be shown the plan, you do not need to change anything. | ||
1. The tests will run, and fail on a single commit. The tests fail because the test script changes. So you need to fix it | ||
1. Change the following strings in `test.sh` | ||
- `One test failed` to `all tests pass` | ||
- `exit 1` to `exit 0` | ||
1. Stage `test.sh` and use `git commit --amend` to fix the broken commit | ||
1. Run `git rebase --continue` to execute the test suite on the remaining commits | ||
1. You may run `verify.sh` (or `verify.ps1` in PowerShell) to verify your solution | ||
### Example 1: | ||
Adding content to file in last 3 commits using `git rebase -i --exec <command(s)> HEAD~3`. | ||
|
||
1. Run `git log --patch` command to see what changes are include in last commit. | ||
2. Run `git rebase -i --exec "echo '1' >> 4.txt && git add 4.txt && git commit --amend --no-edit" HEAD~3` command it will open configured editor with information what command will be executed for each commits which is notified by `exec <command>` you can either modify the command or save and exit the editor to let the command run for that specific commit. | ||
3. Run `git log --patch` command to see what are the changes in commits. | ||
|
||
### Example 2: | ||
Change the author for all the commits using `git rebase -i --exec`. | ||
|
||
1. Run `git log --format="commit: %H%nauthor: %an%n"` command to see detail related to commit and author. | ||
2. Run `git rebase -i --root --exec "git commit --amend --author='my name <[email protected]>' --no-edit"` command it will open configured editor with information what command will be executed for each commits which is notified by `exec <command>` you can either modify the command or save and exit the editor to let the command run for that specific commit. | ||
3. Run `git log --format="commit: %H%nauthor: %an%n"` command to see the changes author information for the commits. | ||
|
||
## Useful commands | ||
|
||
- `git log --patch` | ||
- `git rebase -i --exec "echo '1' >> 4.txt && git add 4.txt && git commit --amend --no-edit" HEAD~3` | ||
- `git log --format="commit: %H%nauthor: %an%n"` | ||
- `git rebase -i --root --exec "git commit --amend --author='my name <[email protected]>' --no-edit"` or `git rebase -i --exec "git commit --amend --author='my name <[email protected]>' --no-edit" first-commit` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.