Upgrade to Pro — share decks privately, control downloads, hide ads and more …

HelloGit2.pdf

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →
Avatar for marcio0 marcio0
December 08, 2011
29

 HelloGit2.pdf

Avatar for marcio0

marcio0

December 08, 2011

Transcript

  1. # Envia o branch para o remoto e seta o

    tracking $ git checkout -b feature_branch $ git push -u origin feature_branch Enter passphrase for key '/home/mcruz/.ssh/id_rsa': Total 0 (delta 0), reused 0 (delta 0) To [email protected]:JTQN/nvrisos.git * [new branch] feature_branch -> feature_branch Branch feature_branch set up to track remote branch feature_branch from origin.
  2. # Cria o branch local ‘new_feature_branch’ com tracking para o

    branch ‘origin/new_feature_branch’. $ git branch -a * master remotes/origin/new_feature_branch $ git checkout -b new_feature_branch origin/new_feature_branch Branch new_feature_branch set up to track remote branch new_feature_branch from origin. Switched to a new branch 'new_feature_branch'
  3. # seta o upstream para o branch, para permitir push

    sem especificar branch remoto $ git branch --set-upstream new_feature origin/new_feature_branch Branch new_feature set up to track remote branch new_feature_branch from origin.
  4. $ git remote show origin * remote origin Fetch URL:

    [email protected]:JTQN/nvrisos.git Push URL: [email protected]:JTQN/nvrisos.git HEAD branch (remote HEAD is ambiguous, may be one of the following): master new_feature_branch Remote branches: feature_branch tracked master tracked new_feature_branch tracked Local branches configured for 'git pull': master merges with remote master new_feature merges with remote new_feature_branch Local ref configured for 'git push': master pushes to master (up to date)
  5. $ git pull --rebase remote: Counting objects: 8, done. remote:

    Compressing objects: 100% (4/4), done. remote: Total 6 (delta 4), reused 4 (delta 2) Unpacking objects: 100% (6/6), done. From github.com:JTQN/nvrisos f79d7db..c1fa959 feature -> origin/feature First, rewinding head to replay your work on top of it... Applying: lolcal x Using index info to reconstruct a base tree... Falling back to patching base and 3-way merge... Auto-merging urls.py CONFLICT (content): Merge conflict in urls.py Failed to merge in the changes. Patch failed at 0001 lolcal x $ vim urls.py $ git add urls.py $ git rebase --continue (ou --abort)
  6. MERGE - Mantém histórico de branches (exceto para fast-forward). Uso

    recomendado: Merge de um feature-branch no master (para manter histórico do branch, evitar o fast-forward com --no-ff).
  7. REBASE - Reescreve o histórico do branch. - Permite o

    envio de alterações limpas, sem conflitos para quem fará o merge com o master. - Não deve ser usado caso algum commit já tenha sido enviado com push. Caso o branch já exista no remoto, pode haver duplicação de commits, e também merges complicados se outra pessoa estiver trabalhando no mesmo branch.
  8. Uso recomendado: Trazer atualizações no branch remoto quando nenhum commit

    local foi enviado ainda. Atualizar a referencia do master antes de enviar um pull request/to-review. Assim o merge para quem fará o review será apenas um fast-forward e não haverão conflitos (eles terão sido resolvidos no momento do rebase). Evitar merging branches para atualizações remotas com git pull --rebase.