git --git-dir /foo/bar/ rest-of-git-command
ref:
--git-dir=<path>Set the path to the repository. This can also be controlled by setting the GIT_DIR environment variable. It can be an absolute path or relative path to current working directory.
Em uma função de peixe, posso executar um comando de um determinado diretório sem alterá-lo?
ou
Posso executar um comando git ( push ) de fora do repositório, especificando seu caminho de alguma forma?
Eu gostaria de fazer algo assim:
function backup
set BKDIR /flash/drive
rsync -av $HOME/important/ $BKDIR/important/
cd $HOME/git_repo
git push flash master
end
Mas não quero mudar para outro diretório. Seria ótimo se eu pudesse sincronizar o repositório git como quando eu uso o rsync: especificando o diretório de origem, mas não alterando o diretório de trabalho.
Suponho que um último recurso seria gravar o diretório atual no início e voltar para ele no final.
git --git-dir /foo/bar/ rest-of-git-command
ref:
--git-dir=<path>Set the path to the repository. This can also be controlled by setting the GIT_DIR environment variable. It can be an absolute path or relative path to current working directory.
@RaGe tem a resposta correta.
Uma resposta específica do peixe é usar o pushd e depois o popd
function backup
# ...
pushd $HOME/git_repo
git push flash master
popd
end