Using Git

Provides essential instructions and best practices for developers using Git to manage source code and contribute to MariaDB.

Getting the Source

If you just want to get the latest source and don't require the ability to push changes to the MariaDB repository, you can use the following command to check out the latest branch (replace 10.5 with latest or the latest branch version):

git clone -b 10.5 https://github.com/MariaDB/server.git

Setup of git for MariaDB

  • Set your name with git

git config --global user.name "Ivan Ivanov"
git config --global user.email "ivan@mariadb.com"
git clone git@github.com:MariaDB/server.git
cd server
git checkout 10.5
  • Config repository pull and alias for fast forward:

git config pull.ff only
git config --global alias.ff "merge --ff-only"

Commit Comments

In git commit messages are normally formatted like this:

That is, the first line is considered a subject, much like email subject. Many git commands and pages on GitHub only show the commit subject, not the complete comment. After the subject goes an empty line, then the detailed description of the comment. Structure your commit comments this way, and don't forget the empty line.

Branches

In Git, each repository has only one branch that is currently checked out.

List Existing Branches

To see which branches exists locally and remotely:

To Move to Work on a Specific Branch

Note that if the output from git branch --all is remotes/origin/XXX you should just use XXX as branch name.

Making a Local Copy of a Branch (Like bzr clone)

Remove Last Commit From a Branch

Fetch a Branch Someone Has Done a Rebase on

If you get the following error on pull:

Instead of removing your copy and then clone, you can do:

Other Things About Branches

  • Note: branches whose names start with bb- are automatically put into the buildbot.

Commit Emails

In the MariaDB project, it is a good idea (and a long tradition since MySQL Ab) to have all your commits sent to a commits@mariadb.org mailing list. It allows others to follow the progress, comment, etc.

A script and instructions on how to setup commit triggers in Git are here:. Jira task for commit trigger was MDEV-6278arrow-up-right.

Attributing Code to Someone Else

If you add code on behalf of someone else, please attribute the code to the original author:

  • Run git citool and move changed files to staged.

  • Don't commit, abort instead

  • run git commit --author="Original author name <email_address>"

The above is needed as git citool can't handle the --author option.

Applying a Pull Request

At the end of the pull request page there is a button "Merge pull request" and next to it a link "command line instructions". Click the link, you'll see something like

Step 1: From your project repository, check out a new branch and test the changes.

Step 2: Merge the changes and update on GitHub.

Note where to pull from.

Now, checkout the branch you want to merge it to, say, bb-10.3-stage, and do the following

Now's the time to compile the code, test it, fix, if necessary. Issue these commands:

If you want to do small changes to the pull request, do it in a separate commit, after git rebase @{-1} above. If you want to do big changes to the pull request, perhaps you shouldn't merge it in the first place, but ask the contributor to fix it?

Examples

Diff For Last Commit

Applying New Code From Main Tree to a Branch

You are working on a branch (NEW_FEATURE) and would like to have into that branch all changes from the main branch (10.1).

Applying a Bugfix in the Main Branch

You've just fixed and committed a bug in the main 10.1 branch and want to merge it with the latest 10.1. Often a rebase is better in this case. Assuming your current checked out branch is 10.1:

This will work even if you have done multiple commits in your local 10.1 tree.

Dealing With Conflicts When One Tries to Push

What to do when you have fixed a bug in the main tree but notices that someone has changed the tree since you pulled last time. This approach ensures that your patch is done in one block and not spread out over several change sets.

Finding in Which MariaDB Version a Commit Exists

See Also

This page is licensed: CC BY-SA / Gnu FDL

spinner

Last updated

Was this helpful?