= Server = || Server Info || `git.math.uzh.ch` || || Software || [[http://gitlab.org/|Gitlab]] || || Git push/pull access || mainly via SSH over `git@git.math.uzh.ch` - ```do not forget to upload your public ssh key``` || || Cheat sheet || [[http://www.git-tower.com/blog/git-for-subversion-users-cheat-sheet/|GIT for SVN users]] || <> = Prerequisites = * [[http://git-scm.com/|Git]] installed (already done on IMATH server). * An SSH keypair - [[https://help.github.com/articles/generating-ssh-keys/|HowTo create private/public ssh keys]] = Create/Request an account = == For Members of I-MATH == * You don't need to request a special account for Gitlab. == For Non-Members of I-MATH == If you wan't to collaborate with a project which is hosted on `git.math.uzh.ch`, you need to request a special Gitlab account. It's best if you write an email with a request to 'support AT math.uzh.ch'. You will then receive an email for validation and first-time login. == After the first-time login == * If you requested an "external" account, you will be asked to change your initial password. * '''Recommended''': You need to provide your public SSH key. This can easily be done on the Gitlab web-interface. = Login to Gitlab on `git.math.uzh.ch` = || '''For Members of I-MATH''' || choose 'LDAP login' || || '''For Non-Members of I-MATH''' || choose 'External login' || = Working with Git = {{{ git COMMAND git@git.math.uzh.ch// }}} = Managing your Projects with Gitlab = Gitlab has quite extensive managing capabilities. * You can, among other things, * Crate/fork/rename/remove projects * Create/delete/join Teams * Assing members with roles to projects * Create/Assing issues * Have a wiki for a project * The gitlab user documentation is found on `https://git.math.uzh.ch/help`. = GIT Best Practise = == New project from scratch == * Create a new project via the webinterface. {{attachment:git.project.png}} * You'll see a summary with the next steps: {{{ Git global setup ---------------- git config --global user.name "First Lastname" git config --global user.email "email@math.uzh.ch" Create a new repository ----------------------- mkdir cd git init touch README.md git add README.md git commit -m "first commit" git remote add origin git@git.math.uzh.ch:.git git push -u origin master Push an existing Git repository ------------------------------- cd existing_git_repo git remote add origin git@git.math.uzh.ch:.git git push -u origin master }}} == GIT daily use == === Local: Add new files to existing repo === {{{ git add }}} === Local: Work on your files === * Commit changes locally {{{ git commit -a }}} * Or at IMATH you can use `git-commit`, which will in every file replace `$Id$` by User/timestamp: {{{ git-commit }}} * Commit changes remote {{{ git push }}} === Local: clone an existing repo to start working on it === {{{ git clone git@git.math.uzh.ch:.git }}} == Purged Remote branches still shown locally == * See: http://stackoverflow.com/a/17320081/1167442 {{{ $ git remote update --prune }}} == Visually show commit history == * `gitg` * Use the git.math.uzh.ch webinterface == Search the commit which breaks something == * Based on binary search. * Give a good and a bad commit. * The `git bisect ...` command looks always for the commit in the middle. Do a check of such a commit and decide to continue the search in the lower or upper half. * https://git-scm.com/docs/git-bisect == Purge a file completely from all commits & branches == * This is not how GIT should be used! * ONLY, ONLY, ONLY do this if it is absolutly necessary! * There might be effects, you're on your own! * Source: https://github.com/nachoparker/git-forget-blob {{{ $ cd $ git-forget-file.sh / }}}