Last active
December 7, 2018 15:02
-
-
Save lanmaster53/a2a686328fe859ab8d666dcdea5659a1 to your computer and use it in GitHub Desktop.
Basic script to update git repository without any history or excess data in .git
This file contains hidden or 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
#!/bin/bash | |
# Basic script to update a git repository without any history or excess data in .git. | |
# Parses the url from .git/config, downloads latest version, and purges everything in .git/ except the config file. | |
# Limitations: | |
# * Only works with the master branch. | |
# * Doesn't account for local virtual environments. | |
# * Doesn't allow for maintaining a stash of changes. | |
if [ -f $FILE ]; then | |
# parse the url from the config file | |
url=`grep -e 'url = ' .git/config | sed 's/.*url = //'` | |
# remove all files from the current directory | |
rm -rf ..?* .[!.]* * | |
# clone the parsed url into the currect directory | |
git clone --depth 1 $url ./ | |
# clean up the .git directory | |
cd .git | |
find . ! -name 'config' -exec rm -rf {} + 2> /dev/null | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment