I have a branch named deployment
and I want to push only the contents of the folder dist
to this branch in my remote repository, deleting all other content.
I have tried so far
git push
with --prefix
cd dist
and git push
Observations
How do I select only dist/
folder in my commit?
As I understand, you want to
Commit only a specific directory to a remote branch (deleting all other content)
Since deployment
is created (branched out) from a branch that has all the files, you will need to delete unwanted files in the deployment
branch. You can get to the desired state with the following steps:
git reset --hard HEAD; git fetch
git checkout deployment
find * -maxdepth 0 -name 'dist' -prune -o -exec rm -rf '{}' ';'
git add .
git commit -m "Commit message"; git push origin deployment
Hope it helps!