Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #FTP push changes from a specific Git commit
- #Works by creating a temp branch from the commit
- #and pushing that version of each file that was modified
- #or created by that commit. Then change back to the previous branch
- #and delete the temp branch.
- current_branch = `git branch`.split(/\n/).map{|b| b.strip}.detect {|b| b =~ /^\*/ }.to_s.sub(/^\*\s/,'')
- puts "Current branch is #{current_branch}"
- commit = ARGV[0]
- changed_files = `git show #{commit} --name-only`.split(/\n/)[5..-1].map{|f| f.strip}.reject {|f| f.empty? }
- changed_files.each do |f|
- puts `git diff #{commit} -- #{f}`
- end
- temp_branch = "temp_branch_#{Time.now.to_i}"
- `git checkout -b #{temp_branch} #{commit}`
- puts "Pushing files..."
- #check if exists locally b/c some might have been deleted
- `git checkout #{current_branch}`
- puts "Deleted #{temp_branch}"
- `git branch -d #{temp_branch}`
Add Comment
Please, Sign In to add comment