We use pull requests for all changes. No commits are done directly in to the main branches. The "master" branch is protected and only maintainers can merge to it.
Use descriptive branch names - We commonly use
updates/*as base for the branch names. A good idea is to include the GitHub issue number in the format "
Use descriptive commit messages - Write it so other developers, and your future self, can understand what was changes and why.
Rebase your branch before creating the PR - A rebase makes sure the PR is up to date and has no merge conflicts. Please do a rebase and not just a merge, this gives a clean and readable commit history.
Link the PR to the corresponding issue - A common way is to add "Fixes #1234" at the top of the PR description. See Linking a pull request to an issue
Add a reviewer - If noting else has been agreed upon add Fredrik Jonsson @frjo.
Git command examples¶
Creating a new branch from master¶
First check out master and do a git pull ot get all the latest updates.
Then create a new branch and do a checkout of it.
Pushing branch first time to GitHub¶
First make sure we are in the correct branch. Then push the branch to origin, i.e. GitHub in this case.
HEAD is equivalent to pushing to a remote branch having the same name as your current branch.)
The message in the Terminal will contain the URL to create an PR. On most systems you can Command/CTRL click that to open it directly in your default browser.
Rebase branch if needed¶
Checkout master and update it. Checkout the branch you are working on and issue the command to rebase it from master. If that resulted in any changes you will then need to do a force push to GitHub.
Read more about Git rebase.