Last active
July 31, 2018 02:02
-
-
Save antoniojps/790bd662f405097ddab5ab853def7462 to your computer and use it in GitHub Desktop.
Github commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Iniciar | |
git init | |
# Adds the files in the local repository and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'. | |
# "Stage" | |
git add -A | |
# Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again. | |
git commit -m "First commit" | |
# Commits all and add message | |
git commit -am "message" | |
# Buscar e enviar | |
git push origin master | |
git pull origin master | |
# Para ser case sensitive: | |
git config core.ignorecase false | |
# .gitignore: | |
.DS_Store | |
.idea/ | |
vendor/ | |
.env | |
composer.lock | |
node_modules/ | |
dist/ | |
npm-debug.log | |
yarn-error.log | |
.vscode/ | |
# Criar branch | |
git branch nome | |
# Apagar branch | |
# Local | |
git branch -d nome | |
# Remote | |
git push <remote_name = origin normalmente> --delete <branch_name> | |
# Ver branches | |
git branch | |
# Mudar de branch | |
git checkout nome (master o supe melhor) | |
# Merge de branches (primeiro fazer commits no branch (foo), depois ir para o branch que queremos adicionar(master)) | |
# Exemplo a fazer branch de foo para master | |
git checkout foo | |
git add -A | |
git commit -m "Ficheiros do foo" | |
git checkout master | |
git merge foo | |
# Resolver confitos | |
# Ver quais falharam (vermelho) | |
git status | |
# Abrir ficheiros que falharam | |
<<<< HEAD | |
# aqui esta o codigo que esta no branch em que estamos | |
======== | |
# aqui esta o codigo no outro branch que estamos a tentar fazer mege | |
>>>>> Foo (nome do branch) | |
# Remover os marcadores de conflito e escolher o que deve ou nao ficar | |
# Depois adicionar esses ficheiros "Stage the files" | |
git add ficheiro-do-conflito | |
git commit | |
# Se houver um problema e nao queremos estar a resolver agora podemos abortar | |
# Limpa a diretorio local para o ultimo commit | |
git merge --abort | |
# Conectar a git repo (ser colaborador) | |
git init | |
git remote add origin remote repository URL | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment