-1

I have a local repository that I have cloned from our remote git repository and I have edited a file in this branch. now I need to push this specific file to all remote branches?

how can I do it at one command and not insert it manually to each branch?

Igal S.
  • 13,146
  • 5
  • 30
  • 48
eran meiri
  • 1,322
  • 3
  • 12
  • 29

1 Answers1

1

If you fixed a file on your local branch, it will be pushed to a single remote branch which is the branch upstream.

If you have many remote branches that needs this fix. You need to merge the commit to all those branches. First locally, and then push the changes.

It has to be done manually, or using some script.

git checkout some_local_branch
git cherry-pick <hash of the fix>
git checkout another_local_branch
git cherry-pick <hash of the fix>
....
git push

The last git push will either push all your branches together or just some branches. That depends on your settings.

Igal S.
  • 13,146
  • 5
  • 30
  • 48
  • I have roughly around 40 remote branches. all I want is to update a single file in all of them ( same file and I have no problem with running over the previous version of this file in each branch) – eran meiri Mar 10 '16 at 09:57
  • The only way to update a branch is using a commit. If it is the same commit you want to apply, then you merge it or cherry-pick it. And it most be local branch first, and push branches to remote. Assuming no conflicts, I would say that script is the best way. – Igal S. Mar 12 '16 at 06:44