Submitting Changes¶
We use pull requests for all changes. No commits are done directly in to the main branches. The "main" branch is protected and only maintainers can merge to it.
-
Use descriptive branch names - We commonly use
fix/*
,enhancement/*
,feature/*
andmaintenance/*
as base for the branch names. A good idea is to include the GitHub issue number in the format "*/gh-1234-*
". -
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 nothing else has been agreed upon add Fredrik Jonsson @frjo.
Git command examples¶
Creating a new branch from main¶
First check out main and do a git pull ot get all the latest updates.
Then create a new branch and do a checkout of it.
Adding commits¶
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.
(Pushing to 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 main and update it. Checkout the branch you are working on and issue the command to rebase it from main. If that resulted in any changes you will then need to do a force push to GitHub.
git switch main
git pull
git checkout fix/gh-1234-fixing-thing-a
git rebase main
git push --force-with-lease
Read more about Git rebase.