Avoid pushing a specific branch to the wrong remote

2

Hello,

Does anyone know how to avoid doing gaps with git? At the next thing:

I have a project with 2 configured "remotes" (imagine one of the company - company - and another private - server). I maintain a "branch" that synchronized with the company repository (master -> company / master) and another which I sync with my version of the project that is slightly different (my -> myserver / master).

Now: how do I configure git to prevent me from doing dumbbells and to "push" my personal "branch" to the company server, for example?

    
asked by anonymous 25.07.2015 / 16:45

2 answers

2

First,

Set the push:

git config --global push.default simple

Then, use the "track" with your branch:

git branch master --set-upstream-to=empresa/master
git status         # mostra conexão entre master e empresa/master

Then,

git checkout master
git push                      # Para empresa
git push meuservidor master   # Para seu servidor privado

You can create and use aliases:

git config --local alias.push-empresa "push empresa master"
git config --local alias.push-servidor "push meuservidor master"

git push-empresa
git push-servidor
    
10.03.2016 / 11:01
0

If you use Git with Windows there is a very interesting Powershell extension called posh-git, you can download via Chocolatey here >. This extension shows the name of the current branch at the prompt, ie it is no longer necessary to type git status to check the current branch.

    
27.07.2015 / 08:34