Git and GitHub¶
The sections below describe some A-team best practices for using Git and GitHub. For more general information on Git and how we use it, see the Software and Tools and Development Process sections of the guide.
While projects vary in their opinions on whether merge commits should be avoided or not, it is generally a good idea to rebase a feature branch before submitting a pull request.
Rebasing allows you to alter a series of commits, changing the history of your repository. Typically you rebase a branch to:
- Combine smaller commits made during development into larger, logical commits that are easier to understand and review, or split up larger commits into smaller commits for the same purpose.
- Alter commit messages of previous commits.
- Move a branch to be based on the latest commit of the branch you want to merge into and resolve any conflicts that occur.
If you’re not familiar with rebasing, you can start with this short
guide on how to use the
git rebase command.
These changes all make the code review process as well as the merging process easier, and are recommended for all pull requests.
Rebasing code that has already been pushed to a public or shared repository makes it very difficult for others to update their local repositories. Only rebase branches that you are absolutely sure no one else is using, such as feature branches on your personal fork.