Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to apply a commit to all branches in git?

I have a feeling I am asking something that can't be done in git, but I might as well ask. Is there any way that I can make one change and commit it to all branches? For instance, suppose I want to make a change to my AUTHORS file or LICENSE file. I know I can commit the change to one branch and then cherry-pick it to each branch individually. But is there an easier way to do it?

like image 381
Jason Baker Avatar asked Jan 30 '10 03:01

Jason Baker


People also ask

How do you push a commit to all branches?

To push the all branches to a remote git, we can use the git push command followed by the --all flag and origin. This will create a track with the local branches to the remote branches.

Can I apply a commit to another branch?

You can cherry-pick a commit on one branch to create a copy of the commit with the same changes on another branch. If you commit changes to the wrong branch or want to make the same changes to another branch, you can cherry-pick the commit to apply the changes to another branch.

Does git support commits across the multiple branches?

b) GIT does not support 'commits' across multiple branches or tags. Subversion allows the creation of folders at any location in the repository layout.

Does git push push to all branches?

No, git push only pushes commits from current local branch to remote branch that you specified in command.


2 Answers

If the branches are going to be merged back to the trunk, or rebased on top of the trunk, you won't have to worry about it. They'll pick it up when that happens.

If they're long-lived branches, you'll want to either merge the updated branch into them, or cherry-pick the commit.

like image 89
John Stoneham Avatar answered Sep 20 '22 17:09

John Stoneham


What can help you are Topic Branches. Read this and this blog post.

like image 41
Kornel Kisielewicz Avatar answered Sep 19 '22 17:09

Kornel Kisielewicz