I want to make a single commit on different branches at the same time, since, in my project, I have different branches for different clients.
Say, I have made a new feature commit on Branch A. Can I also make this commit on Branch B, Branch C and D at the same time as well? Is there any short cut command for this? This is very troublesome to checkout one branch, and cherrypick the commit everytime, sometime, if the commit is necessary on many branches, it would be a nightmare for me.
Any simple bash script for this operation?
There is a similar question in there. but rebasing is not that I want.
Yes, two branches can point to the same commits.
If you use git branches a lot, you'll often push each branch after each commit. Instead of pushing every single branch you can do git push --all origin . This will push all commits of all branches to origin.
You can have many branches in your repository, but only one of these will be "checked out" as the working-tree so that you can work on it and make changes. git worktree adds the concept of additional working trees. This means you can have two (or more) branches checked-out at once.
The cherry-pick feature will do the job and will only apply the last commit:
Considering branches A, B
git checkout A git commit -m "Fixed the bug x" git checkout B git cherry-pick A
hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With