Using Git
Contents
Setup
- Set your name with git
git config --global user.name "Ivan Ivanov" git config --global user.email "[email protected]"
- Go to https://github.com/settings/ssh and add your public SSH key (GitHub Help).
- Clone the repository
git clone [email protected]:MariaDB/server.git cd server
- Run
git branchto check that you're working on MariaDB 10.1:
server $ git branch * 10.1
Commit comments
In git commit messages are normally formatted as
subject body more body ...
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. Please, structure your commit comments this way, don't forget the empty line.
Branches
This is an important concept, and git branches do not have equivalents in bzr.
In Bazaar, we all used to have one shared repository, within which there were many branches. This seems to be impossible with git?
In Git, each repository has only one branch that is currently checked out.
git branch
Note: branches whose names start with bb- are automatically put into the buildbot.
Equivalents for some bzr commands
CAVEAT EMPTOR. Check the manual before running!
bzr statusisgit statusbzr diffisgit diffbzr logisgit logbzr revertisgit reset --hardbzr revert filenameisgit checkout filenamebzr revertisgit reset --hardbzr parentisgit remote -v(but there are more detailed commands)bzr pushisgit push REMOTENAME BRANCHNAME. REMOTENAME is typically "origin", for example:git push origin 10.1-new-featurebzr clean-tree --ignoredisgit clean -Xdf(note the capital X!)bzr rootisgit rev-parse --show-toplevelbzr missing --mine-onlyisgit cherry -v origin(kind-of).
GUIs
bzr gcommitisgit citoolbzr vizisgitkbzr gannotateisgit gui blame
Commit emails
In MariaDB project, it is a good idea (and a long tradition since MySQL Ab) to have all your commits sent to a [email protected] 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: http://bazaar.launchpad.net/~maria-captains/mariadb-tools/trunk/files/head:/git_template/ . Jira task for commit trigger was MDEV-6278.
Examples
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).
git checkout 10.1 git pull git checkput NEW_FEATURE git rebase 10.1
Applying a bugfix in the main branch
You've just fix 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 you current checked out branch is 10.1:
git fetch origin git rebase origin/10.1