Git from the command line

Configure Git
Git uses an email-address and a Name for commits. Configure your git with an email-address you use on Github:
git config --global "Fabian Schmid"
git config --global
Additionally configure git to prevent history-changes:
git config --system receive.denyNonFastforwards true
git clone ilias-trunk
cd ilias-trunk
git checkout trunk
Will receive a working copy of the trunk in your local subdirectory ilias-trunk.
git clone ilias-rel50
cd ilias-rel50
git checkout release_5-0
Will receive a working copy of the 5.0.x release branch in your local subdirectory ilias-rel50.
Commiting your changes
git commit -am’Commit Message’
This example explains how to commit bug fixes for the case that a bug is fixed in a stable release branch (here: 5.0) and merged into the trunk afterwards. It uses one installation in /var/www/ilias_dev with 4 ILIAS-Clients (separate Database) for each ILIAS-Verison (trunk, Releases 5.0, 4.4 and 4.3). When activating client selection, this installation can be used for development and testing in all supported versions. Alternatively you can clone a ILIAS-Repo for each supported version, but in this case you habe to push/fetch all changes bevore you can cherry-pick.
Change to the installation, e.g.
cd /var/www/ilias_dev
Checkout the branch you want to fix a bug and get the latest version, e.g. Release 5.0:
git checkout release_5-0
git pull
Make your Bugfix and mark the files you changed, e.g.:
git add file_one.php file_two.php
git commit -m’Bugfix Message and Mantis ID’
Get the latest version to check conflicts:
git pull
Resolve conflicts and mark the conflicted files as resolved:
git add conflicted_file_one.php
git commit -m’Bugfix Message and Mantis ID’
Checkout trunk and cherry-pick the fix:
git checkout trunk
git cherry-pick COMMIT_ID
Push all the changes to Github:
git push origin --all
Resolving conflicts
Suppose you run git pull or merging a branch and some conflicts occur:
git merge trunk
Auto-merging hello.html
CONFLICT (content): Merge conflict in hello.html
Automatic merge failed; fix conflicts and then commit the result.
If you open the hello.html you will see:
<!-- Author: Fabian Schmid ( -->
<<<<<<< HEAD
<link type="text/css" rel="stylesheet" media="all" href="style.css" />
<!-- no style -->
>>>>>>> master
<h1>Hello,World! Life is great!</h1>
The first section is the version of the current branch (style) head. The second section is the version of master branch.
You need to resolve the conflict manually. Make changes to hello.html to achieve the following result.
<!-- Author: Marina Pushkova ( -->
<link type="text/css" rel="stylesheet" media="all" href="style.css" />
<h1>Hello, World! Life is great!</h1>
Mark the file as resolved and commit:
git add hello.html
git commit -m "Merged trunk fixed conflict."
Reverting chances
Sometimes it is necessary to get rid of all local changes that you made and get back to the "official" version. You can revert single files:
git reset filename.php
Or recursively directories or the whole local working copy (if executed on the top level):
git reset --hard