About commits
Assim como ao salvar um arquivo que foi editado, um commit registra alterações em um ou mais arquivos no seu branch. O Git atribui a cada commit um ID exclusivo, denominado SHA ou hash, que identifica:
- Cada uma das alterações feitas;
- O momento em que as alterações foram feitas;
- O autor das alterações.
Ao fazer um commit, você deve incluir uma mensagem que descreva brevemente as alterações. You can also add a co-author on any commits you collaborate on.
Se os commits que você cria em GitHub Desktop estiverem associados à conta errada no GitHub, atualize o endereço de e-mail na configuração do Git usando GitHub Desktop. For more information, see "Configurar o Git para o GitHub Desktop."
Choosing a branch and making changes
-
Create a new branch, or select an existing branch by clicking Current Branch on the toolbar and selecting the branch from the list.
-
Usando seu editor de texto favorito, como o Visual Studio Code, faça as alterações necessárias nos arquivos do projeto.
Choosing how to display diffs
You can change the way diffs are displayed in GitHub Desktop to suit your reviewing needs.
To change how you view diffs, in the top-right corner of the diff view, click .
- To change how the entire diff is displayed, under "Diff display", select Unified or Split. The Unified view shows changes linearly, while the Split view shows old content on the left side and new content on the right side.
- To hide whitespace changes so you can focus on more substantive changes, select Hide Whitespace Changes.
If you need to see more of the file than GitHub Desktop shows by default, you can expand the diff.
- To see the next few lines above or below the highlighted changes, click the arrow above or below the line numbers.
- To see the entire file, right-click in the diff view and click Expand Whole File.
Selecting changes to include in a commit
As you make changes to files in your text editor and save them locally, you will also see the changes in GitHub Desktop.
In the "Changes" tab in the left sidebar:
-
The red icon indicates removed files.
-
The yellow icon indicates modified files.
-
The green icon indicates added files.
-
To access stashed changes, click Stashed Changes.
-
Para adicionar todas as alterações em todos os arquivos a um só commit, mantenha a caixa de seleção na parte superior da lista selecionada.
-
Para adicionar todas as alterações em um ou mais arquivos a um só commit, desmarque as caixas de seleção ao lado dos arquivos que não deseja incluir, deixando apenas os arquivos desejados no commit. Você pode alternar a caixa de seleção com as chaves
Spacebar
ouEnter
depois de selecionar um arquivo.
Creating a partial commit
If one file contains multiple changes, but you only want some of those changes to be included in a commit, you can create a partial commit. The rest of your changes will remain intact, so that you can make additional modifications and commits. This allows you to make separate, meaningful commits, such as keeping line break changes in a commit separate from code or prose changes.
To exclude changed lines from your commit, click one or more changed lines so the blue disappears. The lines that are still highlighted in blue will be included in the commit.
Discarding changes
If you have uncommitted changes that you don't want to keep, you can discard the changes. This will remove the changes from the files on your computer. You can discard all uncommitted changes in one or more files, or you can discard specific lines you added.
Discarded changes are saved in a dated file in the Trash. You can recover discarded changes until the Trash is emptied.
Discarding changes in one or more files
-
Na lista de arquivos alterados, selecione os arquivos dos quais você deseja descartar as alterações desde o último commit. Para selecionar vários arquivos, clique em
shift
e clique no intervalo de arquivos dos quais deseja descartar as alterações. -
Clique em Descartar Alterações ou Descartar Alterações Selecionadas para descartar as alterações feitas em um ou mais arquivos ou Descartar Todas as Alterações para descartar as alterações feitas em todos os arquivos desde o último commit.
-
Para confirmar as alterações, na janela "Confirmar Descartar Alterações", examine os arquivos afetados e clique em Descartar Alterações.
Discarding changes in one or more lines
You can discard one or more changed lines that are uncommitted.
Note: Discarding single lines is disabled in a group of changes that adds and removes lines.
To discard one added line, in the list of changed lines, right-click the line number of the line you want to discard, then select Discard Added Line.
To discard a group of changed lines, right-click the vertical bar to the right of the line numbers for the lines you want to discard, then select Discard added lines.
Write a commit message and push your changes
Once you're satisfied with the changes you've chosen to include in your commit, write your commit message and push your changes. If you've collaborated on a commit, you can also attribute a commit to more than one author.
Note: Por padrão, GitHub Desktop fará o push da tag que você criar no seu repositório com o commit associado. For more information, see "Gerenciar tags no GitHub Desktop."
-
Na parte inferior da lista de alterações, no campo Summary (Resumo), digite uma mensagem de commit curta e significativa. Como alternativa, é possível adicionar mais informações sobre as alterações no campo Description (Descrição).
-
Optionally, to attribute a commit to another author, click the add co-authors icon and type the username(s) you want to include.
-
No campo Descrição, clique em Fazer commit de um BRANCH.
-
If the branch you're trying to commit to is protected, Desktop will warn you.
- To move your changes, click switch branches.
- To commit your changes to the protected branch, click Commit to BRANCH.
For more information about protected branches, see "Sobre branches protegidos."
-
Para enviar por push as alterações locais no repositório remoto, na barra do repositório, clique em Efetuar push de origem.
-
If you have a pull request based off the branch you are working on, GitHub Desktop will display the status of the checks that have run for the pull request next to the "Current Branch" section of the repository bar. For more information about checks, see "Exibir e executar novamente verificações no GitHub Desktop."
If a pull request has not been created for the current branch, GitHub Desktop will give you the option to preview the changes and create one. For more information, see "Creating an issue or pull request from GitHub Desktop."