I have a master
and a development
branch, both pushed to GitHub. I\'ve clone
d, pull
ed, and fetch
ed, but I re
I needed to do exactly the same. Here is my Ruby script.
#!/usr/bin/env ruby
local = []
remote = {}
# Prepare
%x[git reset --hard HEAD]
%x[git checkout master] # Makes sure that * is on master.
%x[git branch -a].each_line do |line|
line.strip!
if /origin\//.match(line)
remote[line.gsub(/origin\//, '')] = line
else
local << line
end
end
# Update
remote.each_pair do |loc, rem|
next if local.include?(loc)
%x[git checkout --track -b #{loc} #{rem}]
end
%x[git fetch]