SóProvas


ID
2639773
Banca
IADES
Órgão
CFM
Ano
2018
Provas
Disciplina
Engenharia de Software
Assuntos

Um dos sistemas mais utilizados para o controle de versão de código é o git. Considere hipoteticamente que um programador inadvertidamente realizou um commit na branch errada utilizando o git. É necessário que ele remova esse commit sem perder o trabalho que ele realizou localmente. O comando que resolverá o problema é

Alternativas
Comentários
  • E)

    git reset [] []

    This form resets the current branch head to and possibly updates the index (resetting it to the tree of ) and the working tree depending on . If is omitted, defaults to "--mixed". The must be one of the following:

    --soft

    Does not touch the index file or the working tree at all (but resets the head to , just like all modes do). This leaves all your changed files "Changes to be committed", as git status would put it.

    --mixed

    Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated. This is the default action.

    If -N is specified, removed paths are marked as intent-to-add (see git-add[1]).

    --hard

    Resets the index and working tree. Any changes to tracked files in the working tree since are discarded.

    --merge

    Resets the index and updates the files in the working tree that are different between and HEAD, but keeps those which are different between the index and working tree (i.e. which have changes which have not been added). If a file that is different between and the index has unstaged changes, reset is aborted.

    In other words, --merge does something like a git read-tree -u -m , but carries forward unmerged index entries.

    --keep

    Resets index entries and updates files in the working tree that are different between and HEAD. If a file that is different between and HEAD has local changes, reset is aborted.

    Fonte: https://git-scm.com/docs/git-reset

  • https://medium.com/@andgomes/os-tr%C3%AAs-tipos-de-reset-aa220658d9b2

  • git push : envia alterações locais para o servidor ( remote )

    git reset --hard HEAD~1 : desfaz commit e perde as alterações nos arquivos

    git stash : armazena alterações na pilha para uso posterior

    git clone: obtém repositório do servidor para a maquina local

    git reset --soft HEAD~1: desfaz commit e não perde alterações nos arquivos