简体   繁体   中英

Commit on parent branch and rebase local branch automatically

I have a situation like this:

  1. I have a main branch master , a feature branch feat and a fixup branch fixes .
  2. The fixes branch hardcodes some assumptions that make it possible to do local development. (Things like not requiring https or licenses or hardware keys. Stuff that I don't want to accidentally push to prod)
  3. I want to stay on fixes branch locally but I want to make commits on the feat branch.
  4. I want the fixes branch to always be on top of feat .

Assume that this is my current situation:

A---B---C <---master
         \
          D---E---F <---feat
                   \
                    G---H <---fixes, HEAD

I do some work and make a commit. This is what I want the result to be:

A---B---C <---master
         \
          D---E---F---I <---feat
                       \
                        G---H <---fixes, HEAD

My idea says that it can be done by first making commit I on fixes then cherry-picking it on feat then resetting fixes to H then rebasing fixes on top of feat .

This seems like a lot of work to do manually. Is there a way to automate this?

I want to stay on fixes branch locally but I want to make commits on the feat branch.

An alternative approach would be to use git worktree , in order to have a separate folder set on feat .
You can create I and push it from that folder.

Back to your regular Git repository working tree, checked out on fixes, you can git rebase feat fixes .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM