I have a git repo in my computer and one of the directories inside this repo is a git worktree that holds the html build of the docs. So the tree goes something like this
. # <--- main branches here!
├── docs
│ └── _build
│ ├── doctrees
│ ├── html # <--- gh-pages branch here!
│ │ ├── _modules
│ │ ├── _sources
│ │ └── _static
│ └── latex
├── examples
└── mypackage
├── subpackages
└── subpackages
When I work at the docs, both branches (dev
and gh-pages
) get updated, because I change the files in the docs
directory and then sphinx compiles the html into the html
directory.
However, when I'm done with the process, I have to manually perform git add . && git commit
in both the main branch and the gh-pages
branch, to then push all changes to git.
This is not awfully troublesome, but it would be handy if I could issue one command for all branches. I know that git push
can be "defaulted" to push all branches (which is what I do) but I found no way of doing this to add and commit such as (for example; just for the sake or clarification)
git add . --allbranches
git commit --allbranches -m "updated the docs"
git push
or something like that. Is there a way to do it?
Cheers!
It's not possible to commit to multiple branches at one time nor to merge branches not currently checked out.
But you can shorten commands a little bit. To add all changes and make a commit, then push in one line
git commit -am "commit message" && git push