mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 23:28:02 +00:00
Add Rebase Commits With An Arbitrary Command as a git til
This commit is contained in:
@@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
|
|||||||
For a steady stream of TILs from a variety of rocketeers, checkout
|
For a steady stream of TILs from a variety of rocketeers, checkout
|
||||||
[til.hashrocket.com](https://til.hashrocket.com/).
|
[til.hashrocket.com](https://til.hashrocket.com/).
|
||||||
|
|
||||||
_543 TILs and counting..._
|
_544 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -165,6 +165,7 @@ _543 TILs and counting..._
|
|||||||
- [List Most Git Commands](git/list-most-git-commands.md)
|
- [List Most Git Commands](git/list-most-git-commands.md)
|
||||||
- [List Untracked Files](git/list-untracked-files.md)
|
- [List Untracked Files](git/list-untracked-files.md)
|
||||||
- [Move The Latest Commit To A New Branch](git/move-the-latest-commit-to-a-new-branch.md)
|
- [Move The Latest Commit To A New Branch](git/move-the-latest-commit-to-a-new-branch.md)
|
||||||
|
- [Rebase Commits With An Arbitrary Command](git/rebase-commits-with-an-arbitrary-command.md)
|
||||||
- [Reference A Commit Via Commit Message Pattern Matching](git/reference-a-commit-via-commit-message-pattern-matching.md)
|
- [Reference A Commit Via Commit Message Pattern Matching](git/reference-a-commit-via-commit-message-pattern-matching.md)
|
||||||
- [Rename A Remote](git/rename-a-remote.md)
|
- [Rename A Remote](git/rename-a-remote.md)
|
||||||
- [Renaming A Branch](git/renaming-a-branch.md)
|
- [Renaming A Branch](git/renaming-a-branch.md)
|
||||||
|
|||||||
29
git/rebase-commits-with-an-arbitrary-command.md
Normal file
29
git/rebase-commits-with-an-arbitrary-command.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# Rebase Commits With An Arbitrary Command
|
||||||
|
|
||||||
|
Interactive rebasing is a powerful way to manage and tend to the history of
|
||||||
|
a git repository. Rewording and squashing commits are fairly common actions.
|
||||||
|
But what if you need to run some arbitrary command against a series of
|
||||||
|
recent commits?
|
||||||
|
|
||||||
|
This is where the `--exec` flag comes in to play.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ git rebase -i HEAD~3 --exec "git commit --amend --reset-authors -CHEAD"
|
||||||
|
```
|
||||||
|
|
||||||
|
This generates an interactive rebase file that you can review and save when
|
||||||
|
ready.
|
||||||
|
|
||||||
|
```
|
||||||
|
pick ea4a215 Add Globally Install A Package With Yarn as a javascript til
|
||||||
|
exec git commit --amend --reset-author -CHEAD
|
||||||
|
pick a4f4143 Add Initialize A New JavaScript Project With Yarn as a javascript til
|
||||||
|
exec git commit --amend --reset-author -CHEAD
|
||||||
|
pick 2f00aeb Add Default And Named Exports From The Same Module as a javascript til
|
||||||
|
exec git commit --amend --reset-author -CHEAD
|
||||||
|
```
|
||||||
|
|
||||||
|
As you can see, the specified command is prepared for execution for each
|
||||||
|
commit involved in the rebase.
|
||||||
|
|
||||||
|
h/t [Patricia Arbona](https://github.com/arbonap)
|
||||||
Reference in New Issue
Block a user