Automatically update all your git files with this Ruby script!
Ever spent neglected to update your git files because there were too many to deal with? My cool coworker Tom Czarniecki showed me this cool script that allows him to update all his git files at once. Here’s how it works!
Step 1: the Ruby script
Open your text editor of choice, create a new file, and save it as gitupdatescript.rb
(or another filename of your choice) in the root of your folder containing git files. Copy and paste the following code into the file:
#!/usr/bin/env ruby
require 'fileutils'
Dir.glob('**/.git').each do |path|
next if File.file?(path) # don't process submodules
start_time = Time.now
project_base = File.expand_path("#{path}/..")
puts "In #{project_base}"
FileUtils.cd(project_base) do
system('git stash')
puts "Update failed" unless system('git pull --rebase')
system('git stash pop')
end
end_time = Time.now
puts "Done in #{end_time - start_time} sec"
puts
end
Step 2: turn the file into an executable
We’ll now be using the command line to allow this file to modify our computer’s files. I use a Mac, so please be sure to translate to other languages as needed (and let me know if it works!). cd
to the folder containing the ruby file we created and enter the following code:
chmod +x gitupdatescript.rb
If your ruby file is located elsewhere, include the path to the file in your command.
Step 3: execute your new script
To run your script, just type ./gitupdatescript.rb
and it should start updating git files!
Upcoming talks
-
Finding Meaning In Design When Nothing Is Fine
We’re all aware: working while under duress is terrible! Especially as a designer. People often talk about design as a superpower because you can illustrate the future—and it often is quite magical. But when your skillset doesn’t feel immediately relevant to your survival, the magic evaporates. In this very personal and relatable talk, I will share my experience with navigating hard times and experiencing a career block. Attendees will learn techniques for overcoming the malaise and building a guided, sustainable design career.
Want to talk?
Got feedback, looking to suggest a future writing topic, or want to invite me to speak at your organization? Send me a message and I'll get back to you as soon as possible!