One of the popular options to deploy something nowadays is git-based deployment (Github pages is a good example). Here’s a recipe to push some content to the remote branch ignoring whatever this branch already has:
mkdir deploy
cd deploy
echo `date` > 1.txt
git init
git add .
git commit -m "autocommit"
git push -u https://github.com/agibalov/git-force-push-experiment.git \
master:deployed --force
cd ..
rm -rf ./deploy
echo DONE
In this snippet:
- The directory
deployis created. - Within that directory, a current time is echoed to
1.txt. - Then, a brand new git repository is created, the entire folder contents are added and committed to the local
master. - After it comes a trick: we take the local
masterand push it to the removedeployedbranch.
See the demo repository here.
Andrey Agibalov