Skip to content

Instantly share code, notes, and snippets.

@dgmike
Last active January 6, 2017 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgmike/68ee4ce83126024cb1cc66461c76850f to your computer and use it in GitHub Desktop.
Save dgmike/68ee4ce83126024cb1cc66461c76850f to your computer and use it in GitHub Desktop.
Comando embutido no git para criar merges para homolog baseado no staging

Como instalar

  • Crie um arquivo chamado git-homolog e coloque-o em uma pasta do seu $PATH.

No meu $HOME/.bashrc eu tenho a seguinte instrução

if [[ -d "$HOME/.bin" ]]; then
  PATH=$HOME/.bin:$PATH
fi

E coloquei o arquivo em $HOME/.bin/git-homolog.

  • Atribua a permissão de execução ao arquivo

Para meu exemplo, usando a alteração acima, execute o seguinte no terminal:

chmod a+x $HOME/.bin/git-homolog
  • Reunicie o terminal

  • Basta utilizar o script

Para isto, você pode executar a seguinte instrução:

git homolog 'origin/feature/#1234567'
#!/usr/bin/env bash
set -e
if [[ "$DEBUG" == "1" ]]; then
set -x
fi
if [ -n "$(git status --porcelain)" ]; then
echo -e "*** There are changes, please resolve it before\n"
git status
exit 1
fi
git checkout master
if ! git branch -l | grep '^ homolog$'; then
git branch -D homolog
fi
git fetch
git branch -f --no-track homolog origin/staging
git branch -u origin/homolog homolog
git checkout homolog
if [[ $* ]]; then
git merge --no-ff $*
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment