Created
January 8, 2015 10:03
-
-
Save korny/779253995464f1205620 to your computer and use it in GitHub Desktop.
Copy a file's master version to your working directory (prefixed with old_)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
source = ARGV.first or raise 'need a file name' | |
basename = File.basename(source) | |
target = File.join File.dirname(source), (basename[/^_/] ? '_old' : 'old_') + basename | |
exec "git show master:#{source} > #{target}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sometimes, you want to have the old and the new version of a file in your editor. Switching between branches can be tedious, and diffs are hard to work with when you want to copy parts of the old code over.
With this, you have both files available at the same time. Just remove the old_file when you're done.