Add / commit a file to all branches
问题 Say I am on a branch and the index is dirty. I made changes to a file x, and I have some other changes too. Is there a way to add file x to all existing branches? Something like this: #!/usr/bin/env bash current_branch="$(git rev-parse --abbrev-ref HEAD)" git add . git commit -am "added x" git fetch origin git for-each-ref --format='%(refname)' refs/heads | while read b ; do git checkout "$b" git checkout "$current_branch" -- x done git checkout "$current_branch"; # finally, check out the