Pull requests (PRs) are a critical feature in GitHub for reviewing, discussing, and merging code changes. This guide covers the process of creating, reviewing, and merging pull requests.
To create a pull request:
-
Push your branch to GitHub using:
git push origin <branch-name>
-
Go to the repository on GitHub.
-
Click the “Pull Requests” tab.
-
Click the “New Pull Request” button.
-
Choose the branch you want to merge into the main branch.
-
Add a title and description explaining your changes.
-
Submit the pull request.
After a PR is created, team members or collaborators can review it:
- Go to the "Pull Requests" tab in the repository.
- Click on the pull request you want to review.
- Leave comments on specific lines or general feedback.
- Approve the changes or request modifications.
When a PR receives feedback:
- Address the comments by making additional commits.
- Push these changes to the same branch associated with the PR.
- The PR will automatically update with the new changes.
Once the PR is approved:
- Go to the PR on GitHub.
- Click the “Merge Pull Request” button.
- Choose to merge or squash the commits (if necessary).
- Confirm the merge.
After successfully merging the PR, it’s common to delete the branch to keep the repository clean:
- You will be prompted with an option to delete the branch on the PR page.
- Click "Delete branch" to remove it.
If you decide not to proceed with a PR:
- Go to the PR on GitHub.
- Click the "Close Pull Request" button to close it without merging.
Pull requests facilitate code review, collaboration, and continuous integration, ensuring higher-quality code before merging it into the main codebase.
- PT-BR
Os pull requests (PRs) são uma funcionalidade essencial do GitHub para revisar, discutir e mesclar alterações de código. Este guia cobre o processo de criação, revisão e mesclagem de pull requests.
Para criar um pull request:
-
Envie seu branch para o GitHub usando:
git push origin <nome-do-branch>
-
Acesse o repositório no GitHub.
-
Clique na aba “Pull Requests”.
-
Clique no botão “New Pull Request”.
-
Escolha o branch que deseja mesclar no branch main.
-
Adicione um título e uma descrição explicando suas alterações.
-
Submeta o pull request.
Após a criação de um PR, membros da equipe ou colaboradores podem revisá-lo:
- Acesse a aba "Pull Requests" no repositório.
- Clique no pull request que deseja revisar.
- Deixe comentários em linhas específicas ou um feedback geral.
- Aprove as mudanças ou solicite modificações.
Quando um PR recebe feedback:
- esolva os comentários fazendo commits adicionais.
- Envie essas alterações para o mesmo branch associado ao PR.
- O PR será automaticamente atualizado com as novas alterações.
Uma vez que o PR é aprovado:
- Vá até o PR no GitHub.
- Clique no botão “Merge Pull Request”.
- Escolha mesclar ou "squash" os commits (se necessário).
- Confirme o merge.
Depois de mesclar o PR com sucesso, é comum deletar o branch para manter o repositório limpo:
- Você será solicitado com a opção de deletar o branch na página do PR.
- Clique em "Delete branch" para removê-lo.
Se decidir não prosseguir com um PR:
- Acesse o PR no GitHub.
- Clique no botão "Close Pull Request" para fechá-lo sem fazer o merge.
Os pull requests facilitam a revisão de código, a colaboração e a integração contínua, garantindo um código de maior qualidade antes de ser mesclado ao código principal.