Click everything except a special branch

My teammate and I are working on the same OpenShift project. we have several branches that should be on the server, so we use the push --all command, each of us (me and my teammate) want to have a local branch (called LocalTest ) for our local tests and design so that the problem when we use push --all origin branches for all branches that include LocalTest .

By the way, I forgot to indicate that sometimes we need to merge other branches into our local one, especially after we pulled their new commits from the server, and also want the cherry to select or even merge (rarely) from our local branch into other branches, which will click on the server.

is there any command in git like git push --all except branch-name and what is the best solution for our problem?

+6
source share
3 answers

git push --all except master would also be a good start

The problem is that the refspec pattern is pretty limited.

The refspec documentation is clear:

Partial globes cannot be used in the template, so this will be unacceptable:

 fetch = +refs/heads/qa*:refs/remotes/origin/qa* 

However, you can use namespaces (or directories) to do something similar .
If you have a QA command that pushes a series of branches, and you want to get the master branch and any of the QA command branches, but nothing else, you can use a configuration section like this:

 [remote "origin"] url = https://github.com/schacon/simplegit-progit fetch = +refs/heads/master:refs/remotes/origin/master fetch = +refs/heads/qa/*:refs/remotes/origin/qa/* 

If you have a complex workflow process in which the QA team promotes branches, developers promote branches, and integration teams promote and collaborate on remote branches, you can easily use the namespace to do this.

This approach also applies to git push with remote.<name>.push entries.

Thus, the default value of git push will push only the needed refspecs ... if the excluded branches are in a separate namespace.

And this is still the whitelist approach : you need to list the branches you want to push for each namespace and leave one namespace that you don't need.


Working example:

 cd /path/to/repos git init example echo test>afile git add . git commit -m "First commit in master" git checkout -b private/abranch echo abranch>>afile git add . git commit -m "First commit in a private branch" git checkout master cd .. git init --bare example.git cd example git remote add origin ../example.git git config remote.origin.push refs/heads/master:refs/remotes/origin/master 
+2
source

The easiest way to do this is to set push.default to matching .

Any branches that you want to move give them the same names as the corresponding branches in the upstream repository. Any branches that you do not want to push, give them names that are not there. Then your push is just a bare git push .

If you want to work with the local version of the upstream branch, just give it a name that does not match, e.g. git checkout -b local/master origin/master

+2
source

One solution would be to have a dedicated local clone in which you have only LocalTest .

You will make your push --all from your current local clone, where you have all your branches.

sometimes we want to merge other branches (especially their new commtis) into our local branch, so there is no idea for a dedicated local clone

This is a good idea: you can add your first clone as a remote of your second clone (which has a local test branch).
This means that you can get any branch from the first clone at any time and merge them into the LocalTest branch.


Alternatively, you can try to prevent the migration of one branch (using a preliminary push, but this will result in the failure of all push -all, which is impractical.

-1
source

Source: https://habr.com/ru/post/1262386/


All Articles