Created
September 9, 2024 14:55
-
-
Save korutx/9cc3595628af37c09c0b0a10ae2770fb to your computer and use it in GitHub Desktop.
Create a disconnected git 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 | |
# Create a disconnected git branch for GitHub Pages | |
# Clone the repository without checking out files | |
git clone --no-checkout https://github.com/yourusername/yourrepo.git | |
cd yourrepo | |
# Create a new orphan branch | |
git checkout --orphan gh-pages | |
# Remove all files from the working directory | |
git rm -rf . | |
# Create an empty README.md and make the first commit | |
echo "# GitHub Pages" > README.md | |
git add README.md | |
git commit -m "Initial commit for GitHub Pages" | |
# Clean up any untracked files | |
git clean -fdx | |
# Push the new branch to origin | |
git push origin gh-pages | |
echo "Disconnected gh-pages branch created and pushed to origin." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment