Ferramentas do usuário

Ferramentas do site


controle_de_versao:git

GIT

Sobre o GIT

Wikipedia:Git

Bloquear push no master

Google
http://stackoverflow.com/questions/19021978/git-how-to-block-push-to-master-branch-on-remote
http://dev.ghost.org/prevent-master-push/

.git/hooks/pre-push
#!/bin/bash
 
protected_branch='master'  
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
 
if [ $protected_branch = $current_branch ]  
then  
    read -p "You're about to push master, is that what you intended? [y|n] " -n 1 -r < /dev/tty
    echo
    if echo $REPLY | grep -E '^[Yy]$' > /dev/null
    then
        exit 0 # push will execute
    fi
    exit 1 # push will not execute
else  
    exit 0 # push will execute
fi
chmod +x pre-push

Programa para utilizar o git localmente

Clone

Criar um clone de um projeto do repositório para seu ambiente de desenvolvimento

git clone ssh://<usuario>@<servidor>:<diretorio>/<projeto.git> <nome_do_clone>
ou
git clone ssh://<usuario>@<servidor>:<diretorio>/<projeto.git>

Clone de um Branch existente

git clone -b <branch> <remote_repo>

Commit

Commit com arquivos modificados

git commit -a -m “texto/descrição do commit

Simples commit

git commit -m “texto/descrição do commit

Adicionar arquivo para commit

git add diretório/nome_do_arquivo

Branch

Lista branch's

Lista todos os branch's e mostra em qual branch você está atualmente
git branch

Criar novo branch

Cria um novo branch e faz checkout automaticamente para este novo branch
git branch <nome-branch>

Criar um novo branch no repositório remoto

git push -u origin <nome-branch>

Apagar um branch local

Para apagar um branch você tem que sair dele fazer checkout em outro branch para poder apagar ele
git branch -d <nome-branch>

git checkout <branch/master>

Push

Publica no repositório remoto
git push origin <master/branch>

Pull

Pega modificações existentes no repositório <master/branch>
git pull

Merge

Faz a união de <branch/master> ou <master/branch>
git merge <branch/master>

Diff

git diff

Status

git status

Log

git log

Manipulação de arquivos

Reset

git reset <diretório/arquivo>

Checkout

git checkout <diretório/arquivo>

controle_de_versao/git.txt · Última modificação: 2022/05/25 16:24 por 127.0.0.1