Guest User

Untitled

a guest
Apr 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #FTP push changes from a specific Git commit
  2. #Works by creating a temp branch from the commit
  3. #and pushing that version of each file that was modified
  4. #or created by that commit. Then change back to the previous branch
  5. #and delete the temp branch.
  6. current_branch = `git branch`.split(/\n/).map{|b| b.strip}.detect {|b| b =~ /^\*/ }.to_s.sub(/^\*\s/,'')
  7. puts "Current branch is #{current_branch}"
  8.  
  9. commit = ARGV[0]
  10. changed_files = `git show #{commit} --name-only`.split(/\n/)[5..-1].map{|f| f.strip}.reject {|f| f.empty? }
  11.  
  12. changed_files.each do |f|
  13. puts `git diff #{commit} -- #{f}`
  14. end
  15.  
  16. temp_branch = "temp_branch_#{Time.now.to_i}"
  17. `git checkout -b #{temp_branch} #{commit}`
  18.  
  19. puts "Pushing files..."
  20. #check if exists locally b/c some might have been deleted
  21.  
  22. `git checkout #{current_branch}`
  23.  
  24. puts "Deleted #{temp_branch}"
  25. `git branch -d #{temp_branch}`
Add Comment
Please, Sign In to add comment