Hao Wu
Hao Wu

Reputation: 20867

Is there a way to set a branch always rebased from another branch?

So I have a branch called branchA which diverged from branch develop

develop
   └ branchA

After someone pushed into the develop branch, I'd like the branchA also have the updates.

develop - develop(HEAD)
   └ branchA

So I did git rebase develop :

develop - develop(HEAD)
             └ branchA

This works fine. But is there a setting that makes branchA always rebased from develop?

So I can immediately have the updated contents after someone has pushed into the develop branch?

Upvotes: 0

Views: 35

Answers (1)

Aryeh K
Aryeh K

Reputation: 311

Not sure if this will solve your issue, but you could set up a post-checkout hook that will do the rebase every time you check out branchA In short: add a file called post-checkout in your .git hooks folder:

.git/hooks/post-checkout

make the file executable (chmod +x) and in it you can add an if statement (checking that you are on branchA as a condition for rebasing)

You can check out the git hooks documentation here for more information: https://git-scm.com/docs/githooks

Good luck!

Upvotes: 1

Related Questions