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
-
Advancing Beyond Senior Roles: Navigating Non-Management Career Paths
This unique gathering is designed for professionals seeking pathways to growth that don't necessarily lead to traditional management roles. Led by Catt Small, this session invites attendees to share their experiences, challenges, and strategies in carving out impactful, non-managerial career trajectories. Engage in candid discussions about alternative leadership roles, lateral moves that enrich skills skill , and roles that expand influence without the traditional management responsibilities. This is a unique opportunity to connect with peers facing similar career crossroads, learn from the collective wisdom, and envision new trajectories for your career journey. Join us to redefine career success and discover new paths that align with your expertise and passions. Redefine career success with Catt and unlock new paths that resonate with your expertise and passions.
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!