Simple script to checkout files

Recently, I wrote a script to checkout files from branch because why not. At first I thought of using golang or C#, but bash scripting is the way to go.
In all honestly, this script was made with github copilot, its getting pretty powerful, but this script is also fairly simple.
#!/bin/sh
# this scripts reads files.txt and checks out the files from the repository from the inputted branch
# argument 1: branch name# argument 2: file.txt
# check if the branch existsif ! git show-ref --verify --quiet refs/heads/$1then echo "Branch does not exist" exit 1fi
# check if file existsif [ ! -f $2 ]then echo "File does not exist" exit 1fi
# read the file and check out the fileswhile read linedo # convert line from windows path to unix path line=$(echo $line | sed 's/\\/\//g') echo "git checkout $1 -- $line" git checkout "$1" -- "$line"done < $2Since I use windows + git bash we will need a convert windows file paths to unix, for now I use a simple approach of just parsing backslash.
For example a sample file.txt can be
package.jsonapp/src/file.goeshere.txt© 2026 David Li · Home · Blog · RSS ·Classic site · Built with Astro, Starlight and three.js