Skip to content

Instantly share code, notes, and snippets.

@rajeshvaya
Last active August 29, 2015 14:23
Show Gist options
  • Save rajeshvaya/882246f532cde78cc365 to your computer and use it in GitHub Desktop.
Save rajeshvaya/882246f532cde78cc365 to your computer and use it in GitHub Desktop.
Git (print) checkout only updated files of a commit / or commit range
#!/bin/bash
function git_checkout_commit_files(){
# ${1} is the remote branch location
# ${2} is the commit id
printf "Starting to checkout files from remote/branch: ${1} at commit: ${2}\n"
sleep 1
printf "Fetching updates from git, please wait...\n"
git pull && printf "Successfully fetched update from ${1}\n Checking-out the files now, please wait..." && sleep 1 && git diff-tree --no-commit-id --name-only -r ${2} | xargs git checkout ${1}
}
#!/bin/bash
function git_print_checkout_commit_files(){
# ${1} is the remote branch location
# ${2} is the commit id
printf "Fetching updates from git, please wait...\n"
git fetch && printf "Successfully fetched update from ${1}\n printing checkout commands now, please wait...\n\n" && sleep 1 && git diff-tree --no-commit-id --name-only -r ${2} | xargs -n1 echo "git checkout ${1} "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment