|
|
# Using Git
|
|
|
|
|
|
## Download the repo
|
|
|
|
|
|
git clone https://git.ufz.de/mhm/mhm.git
|
|
|
|
|
|
## Configure the default remote repo
|
|
|
|
|
|
Your default remote repository should be GitLab. I.e., your `.git/config` should contain something like this:
|
|
|
|
|
|
```
|
|
|
[remote "origin"]
|
|
|
url = https://git.ufz.de/mhm/mhm.git
|
|
|
fetch = +refs/heads/*:refs/remotes/origin/*
|
|
|
[branch "master"]
|
|
|
remote = origin
|
|
|
merge = refs/heads/master
|
|
|
```
|
|
|
|
|
|
By default, `origin` is the name of your remote (i.e., Gitlab).
|
|
|
|
|
|
## Information
|
|
|
|
|
|
Show current status:
|
|
|
|
|
|
git status
|
|
|
|
|
|
Show commit history:
|
|
|
|
|
|
git log
|
|
|
|
|
|
## Get the latest update
|
|
|
|
|
|
git pull
|
|
|
|
|
|
This is like `svn update`.
|
|
|
|
|
|
## Developing code
|
|
|
|
|
|
> *NOTE:* GitLab is not yet ready for code development. Please use the SVN repo. It is planned to migrate from SVN to Git in the course of 2018.
|
|
|
|
|
|
Add untracked files:
|
|
|
|
|
|
git add .
|
|
|
|
|
|
Also track empty folders (git ignores empty folders):
|
|
|
|
|
|
touch path/to/empty/folder/.gitkeep
|
|
|
|
|
|
Show changes:
|
|
|
|
|
|
git diff
|
|
|
|
|
|
Commit changes:
|
|
|
|
|
|
git commit -am "branch: some changes made"
|
|
|
|
|
|
In contrast to SVN, you can commit on you local copy of the repo without touching the remote repo.
|
|
|
In contrast to SVN, using Git gets easier if you commit more often (i.e., even small changes).
|
|
|
|
|
|
## Merge conflicts
|
|
|
|
|
|
Ususally, the content of both conflicting files are merged into the current file and seperated by `<<<<<<` and `>>>>>>` lines. Edit the file and tidy up those differences, then commit again.
|
|
|
|
|
|
## Push commits to GitLab
|
|
|
|
|
|
git push
|
|
|
|
|
|
SVN pushes everytime it commits. In Git, these are two separate things, such that you can develop and commit your code locally, and push them to the remote later.
|
|
|
|
|
|
## Deployment
|
|
|
|
|
|
Add a (release-)tag to the last commit:
|
|
|
|
|
|
git tag -a v5.9 -m "mHM release version 5.9"
|
|
|
|
|
|
Push tag label to remote (they are not transfered with a normal push):
|
|
|
|
|
|
git push origin v5.9
|
|
|
|
|
|
If not existing, add a link to the remote GitHub.com repo:
|
|
|
|
|
|
git remote add github https://github.com/mhm-ufz/mhm.git
|
|
|
|
|
|
Push the latest release (of the master branch) to GitHub.com:
|
|
|
|
|
|
git push github master
|
|
|
git push github v5.9
|
|
|
|
|
|
The changes should now be on [GitHub.com](https://github.com/mhm-ufz/mhm). |
|
|
\ No newline at end of file |