On Wed, Oct 06, 2021 at 03:13:11PM +0200, Uwe Brauer wrote: > I am facing the following situation, a repository I contribute to, has > at least 3 main branches (2 besides master/main). > > Now I sometimes create branch for my own for some fix etc, but I don't > want to push that branch. > > So if you did some changes in the other branches, I would like to push > them but not my private one. > > I know who to push certain branches, but I don't know who to exclude > certain branches from the push (in mercurial I do this by a concept > called phases, but this does not exist in git), so any change to do this > in git?
What command are you currently using to push "all main branches" or had you also implicitly asked how to do that? The full form of the `git push` command is $ git push <remote> <refspec> [<refspec> ...] "The refspec" tells Git what remote objects - branches and tags - to update with what local objects; the details are in the "gitrevisions" manual page - you can run `git help revisions` to read it. Now a command to push all local branches to update same-named branches in the remote repository is this: $ git push <remote> 'refs/heads/*:refs/heads/*' That "refs/heads/" can be thought of as a namespace containing all the branches (and you can use your file browser of choice to explore the contents of the ".git" directory of your local clone - you'll find there that "refs" directory with the "heads" subdirectory in it, and there will be a set of files representing your local branches). So if we need to differentiate between "public" and "private" local branches, a way to achieve this would be to make a habit to name all "public" branches with some fixed prefix — say, "pub". Then, you could push all such branches in one go by running $ git push origin 'refs/heads/pub/*:refs/heads/*' and even add an alias like $ git config --global --add alias.publish 'push origin refs/heads/pub/*:refs/heads/*' to be used like $ git publish The inconvenience is that you need to remember to create your local branches using that convention (and rename current branches - which is easy to do by using the `git branch -M` command). -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/git-users/20211006151604.4ilyswvvdzzabska%40carbon.