Last active
July 3, 2025 23:39
-
-
Save mikerochip/f0f1fe53976e257a579c8bbae89a81fa to your computer and use it in GitHub Desktop.
Clone a repo and normalize line endings to CRLF (for GitBash on Windows)
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 -e | |
# Prompt for inputs | |
if [[ -z $OWNER ]]; then | |
read -rp "GitHub Owner (set OWNER to skip this): " OWNER | |
if [[ -z $OWNER ]]; then | |
echo "Missing OWNER" | |
exit 1 | |
fi | |
fi | |
if [[ -z $REPO ]]; then | |
read -rp "Repo Name (set REPO to skip this): " REPO | |
if [[ -z $REPO ]]; then | |
echo "Missing REPO" | |
exit 1 | |
fi | |
fi | |
# delete existing if there | |
echo "" | |
echo "Delete existing $REPO" | |
rm -rf $REPO | |
# clone | |
RepoUrl=https://github.com/$OWNER/$REPO.git | |
echo "" | |
echo "Clone $RepoUrl" | |
git clone $RepoUrl | |
# cd to repo | |
echo "" | |
echo "cd $REPO" | |
cd $REPO | |
echo "$(pwd)" | |
# set config | |
echo "" | |
echo "Set git config to crlf" | |
git config core.eol crlf | |
git config core.autocrlf true | |
# renormalize repo...this way seems the most straightforward | |
echo "" | |
echo "Remove and hard reset repo" | |
git rm --force -r . | |
git reset --hard | |
echo "" | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment