Last active
July 17, 2023 13:27
-
-
Save scott1991/1c0c49a258e60102e3b9afcaf95e0358 to your computer and use it in GitHub Desktop.
A script to create a tar archive from a directory, excluding files as per the .gitignore file.
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 | |
if [ $# -eq 0 ]; then | |
echo "Please provide the target directory path as an argument." | |
exit 1 | |
fi | |
CURRENT_DIR=$(pwd) | |
TARGET_DIR=$1 | |
DIR_NAME=$(basename $TARGET_DIR) | |
# Change to the target directory | |
cd $TARGET_DIR | |
# Create the archive using tar command | |
tar -cvf ${CURRENT_DIR}/${DIR_NAME}.tar $(git ls-files) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment