Created
September 2, 2023 11:31
-
-
Save OllieJT/39bb6d1253bda03b0f3f93f623b3d3b5 to your computer and use it in GitHub Desktop.
cpgit - Copies a node project to a new directory while excluding node_modules and git history
This file contains 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 | |
# Copies a node project to a new directory while excluding node_modules and git history | |
# Check for both source and destination directory arguments | |
if [ "$#" -ne 2 ]; then | |
echo "Required arguements: source_directory new_directory" | |
exit 1 | |
fi | |
# Define source and new directory names | |
SOURCE_DIR="$1" | |
NEW_DIR="$2" | |
# Perform recursive copy while excluding certain folders | |
rsync -av --exclude '/node_modules' --exclude '/.git' "$SOURCE_DIR/" "$NEW_DIR/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Recommended Setup
Assuming you save this to
~/scripts/cpgit.sh
Make the file executable
chmod +x ~/scripts/cpgit.sh
Alias the script in your
~/.bashrc
or~/.zshrc
fileExample usage