Skip to content

Instantly share code, notes, and snippets.

@roneygomes
Last active October 2, 2015 02:01
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 roneygomes/b100bd1e9dbebd7e2672 to your computer and use it in GitHub Desktop.
Save roneygomes/b100bd1e9dbebd7e2672 to your computer and use it in GitHub Desktop.
Git Tutorial

Configurações Gerais

  • Criando um repositório:

  • git init

  • Clonando um repositório:

  • git clone ssh://git@nlpmobile:33000/travelg.git

  • Configurando nome do usuário:

  • git config --global user.name "Roney Gomes"

  • Configurando e-mail:

  • git config --global user.email roneygomes@great.ufc.br

  • Define o editor de texto padrão:

  • git config --global core.editor notepad++

Salvando Alterações

  • Marcando alterações para submissão:

  • git add <arquivo>

  • git add .

  • git add --all

  • Registrando as alterações:

  • git commit

  • git commit -m "This is the rhythm of the night..."

  • Marcando e comitando:

  • git commit -am "Marcando e comitando tudo porque eu sou preguiçoso."

  • Submetendo as alterações

  • git push

  • git push origin <branch>

Inspecionando um Repositório

  • Estado atual do repositório.

  • git status

  • Histórico de alterações.

  • git log

  • git log -n <limite>

  • git log --oneline

  • git log --stat

  • git log -p

  • git log --author="<padrão>"

Operações de Branches

  • Criando um branch:

  • git branch <nome-do-branch>

  • Mudando de branch:

  • git checkout <nome-do-branch>

  • Criando e mudando:

  • git checkout -b <nome-do-branch>

  • Apagando um branch:

  • git branch -d <nome-do-branch>

  • git branch -D <nome-do-branch>

Desfazendo Alterações

  • Limpando a staging area:

  • git checkout .

  • git checkout -- <arquivo>

  • Revertendo alterações de forma segura:

  • git revert <commit>

  • git revert <commit> <arquivo>

  • Revertendo alterações de forma insegura:

  • git reset <commit>

  • git reset --hard <commit>

  • git reset HEAD~2

  • Removendo arquivos não versionados:

  • git clean -xf

  • git clean -df

  • git clean -f <caminho>

  • Alterando o commit mais recente:

  • git commit --amend

  • git commit --amend --no-edit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment