I\'ve set up tracking branches with the --track option, and when I do a git pull on master, it fetches all branches to origin/br
The following one-liner fast-forwards all branches that have an upstream branch if possible, and prints an error otherwise:
git branch \
--format "%(if)%(upstream:short)%(then)git push . %(upstream:short):%(refname:short)%(end)" |
sh
It uses a custom format with the git branch command. For each branch that has an upstream branch, it prints a line with the following pattern:
git push . :
This can be piped directly into sh (assuming that the branch names are well-formed). Omit the | sh to see what it's doing.
The currently checked-out branch will not be updated with a message like
! [remote rejected] origin/master -> master (branch is currently checked out)
For this, you can resort to regular git pull --ff-only .
Add the following to your .gitconfig so that git fft performs this command:
[alias]
fft = !sh -c 'git branch --format \"%(if)%(upstream:short)%(then)git push . %(upstream:short):%(refname:short)%(end)\" | sh' -
The alias is a shorthand to "fast-forward tracking (branches)".