Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a folder containing many files of the form svs_a.png, svs_b.png, svs_xyz.png, svs_something.png, ... svs_final.png. These are all different versions of the same file named according to the bad old "rename each version" system. The folder has now become too cluttered though, and I'm feeling like an idiot for not using a proper VCS from the start. I'd like to pull these all into a git repo now, and it would be great if I could pull each of these into the repo as different versions of the same file. Is there a way to make git do that?

There's also a few files named svs_color_a.png, ... svs_color_final.png which I'd like to store in a different branch of the repo (say named "color").

share|improve this question

Assuming a Linux system:

#!/bin/sh -e
import_files() {
    for file; do
        date=$(stat -c %y "$file")
        cp "$file" svs.png; git add svs.png
        git commit -m "Imported $file" --date="$date"
git init
import_files svs_{first,second,third,fourth,.....,final}.png
git checkout --orphan color
import_files svs_color_{first,second,third,...,final}.png

Using git checkout --orphan creates a completely separate branch. Using git checkout -b instead would create a branch continuing from the last commit in master.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.