Created
March 11, 2023 13:44
-
-
Save jericbas/f0ae9dc393ad6b87cdef71ddd328db47 to your computer and use it in GitHub Desktop.
Build Gatsby and push the contents of the public directory to another branch
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 | |
# Build the Gatsby site | |
npm run build | |
# Create a new branch for the build files | |
git branch build-files | |
# Checkout the new branch | |
git checkout build-files | |
# Remove all files from the branch except the .gitignore file | |
git rm -r --cached . | |
git reset -- .gitignore | |
# Move the contents of the public/ directory to the root of the branch | |
mv public/* . | |
# Commit the changes | |
git add . | |
git commit -m "Add build files" | |
# Push the changes to the remote branch | |
git push -u origin build-files | |
# Switch back to the previous branch | |
git checkout - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment