Add a --no-history optin to avoid growing branch weight
Closed this issue · 6 comments
Hi there,
First of all, thanks for you tool. It's really useful and easy to use.
As a new feature, I would suggest to add a --no-history
option.
Deploying regularly to the branch gh-pages
make its the git history growing again and again. But this branch (or any branch used to host static content) doesn't really need to be versioned into the history.
There is a similar tool written in nodejs which has an option --no-history
to overwrite the previous commit: gh-pages. It's reported that it works well, as it in a GH Action.
- name: deploy to gh pages
run: |
echo "Deploying to directory: ${{env.BRANCH_NAME}}"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
npx gh-pages --dist dist/ --dest ${{env.BRANCH_NAME}} --remove "${{env.BRANCH_NAME}}/**" --no-history --repo "https://${GITHUB_ACTOR}:${{secrets.GITHUB_TOKEN}}@github.com/${GITHUB_REPOSITORY}.git"
NPM option: https://www.npmjs.com/package/gh-pages#optionshistory
Original issue: geotribu/website#302 by @fgravin
I added a new option -o or --no-history in a46fa5d.
Thanks for being such reactive!
Could you please try out the new version and verify that this fixes your scenario?
Yes. I'll give it a try (probably tomorrow).
@c-w, just tried locally running ghp-import --force --no-jekyll --push docs/_build/html --no-history
and got this error: ghp-import: error: Failed to rebase gh-pages branch.
@Guts Thanks for trying it out. Could you provide some more details on your environment (e.g. how was the gh-pages branch created? What version of git are you running? What OS? Is the repo open source so that I could take a look at the setup?) so that I can try to reproduce this issue? The current implementation works on ghp-import
's CI setup so there must be some difference between my environment and yours that we need to track down.
You're right, here comes more information to track on this.
Sys info
$ git --version
git version 2.31.0
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
Repository used to test
Repo main page: https://github.com/Guts/DicoGIS
gh-pages branch: https://github.com/Guts/DicoGIS/tree/gh-pages
Published doc: https://guts.github.io/DicoGIS/ with page about doc process https://guts.github.io/DicoGIS/development/documentation.html
Github Action: https://github.com/Guts/DicoGIS/blob/master/.github/workflows/docs_builder.yml
Conclusion
It was just about options order and positional arg:
- 🔴
ghp-import --force --no-jekyll --push docs/_build/html --no-history
- ✔️
ghp-import --force --no-jekyll --push --no-history docs/_build/html
😉