Skip to main content

Rebase multiple branches at once

Project description

git-rebase-branches

Rebase multiple branches at once.


Say I have a number of feature branches, and new commits are added to main:

dmtucker@localhost:/tmp/tmp.97ZHC4YUiK $ git branch -vv
  feature1 2511789 Add feature #1
  feature2 339ff60 Make fizz do buzz
* feature3 618d195 Improve thing greatly
  main     77bf560 New commits to main!

My feature branches are no longer based on main and all need to be rebased:

dmtucker@localhost:/tmp/tmp.97ZHC4YUiK $ git log --graph feature1 feature2 feature3 main
* 618d195 (HEAD -> feature3) Improve thing greatly
| * 339ff60 (feature2) Make fizz do buzz
|/
| * 2511789 (feature1) Add feature #1
|/
| * 77bf560 (main) New commits to main!
|/
* cd9b6c6 Initial commit

git-rebase-branches can help with that:

dmtucker@localhost:/tmp/tmp.97ZHC4YUiK $ git-rebase-branches main
$ git for-each-ref --no-contains main '--format=%(refname:short)' refs/heads/
feature1
feature2
feature3
$ git stash push --include-untracked
No local changes to save
$ git log -n1
618d195 (HEAD -> feature3) Improve thing greatly
$ git rebase main feature1
Successfully rebased and updated refs/heads/feature1.
$ git rebase main feature2
Successfully rebased and updated refs/heads/feature2.
$ git rebase main feature3
Successfully rebased and updated refs/heads/feature3.
$ git -c advice.detachedHead=false checkout feature3
Already on 'feature3'

==================================== SUMMARY ====================================
- feature1 (succeeded)
- feature2 (succeeded)
- feature3 (succeeded)
  • Note: Once you run the first command, git-rebase-branches prints and runs the rest.

Now, all feature branches are based on main:

dmtucker@localhost:/tmp/tmp.97ZHC4YUiK $ git log --graph feature1 feature2 feature3 main
* 069fcca (HEAD -> feature3) Improve thing greatly
| * e32b491 (feature1) Add feature #1
|/
| * 8fffd21 (feature2) Make fizz do buzz
|/
* 77bf560 (main) New commits to main!
* cd9b6c6 Initial commit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git_rebase_branches-2.1.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_rebase_branches-2.1.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file git_rebase_branches-2.1.0.tar.gz.

File metadata

  • Download URL: git_rebase_branches-2.1.0.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.25

File hashes

Hashes for git_rebase_branches-2.1.0.tar.gz
Algorithm Hash digest
SHA256 c7050ff2f1dd46da32e0371d20f4a8bd0685282787b02ed613d45b8da4743dd5
MD5 50410a59b4c51b9ae28a0625ea2fc7de
BLAKE2b-256 7546f2ff458517ebe3eb465a9f1635e82fe42d048780df1cd54bed1bc29ccaf9

See more details on using hashes here.

File details

Details for the file git_rebase_branches-2.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for git_rebase_branches-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43b0e6c010cfe93b199087d0736872e6dc83e6a7db110110ab4b7e16b4aee85a
MD5 e0139fda9f0f75daf10b0e16e66420ba
BLAKE2b-256 0b7bb622e2b8b6fb50783cb3935ebb43a46f2a9f8d083dc9a06c446977f3b239

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page