Week 1 - Tutorial: Open Source & Git

Sebastian Ebert

April 16, 2015

Today

  • Organizational things
  • Open source project structure
  • Gitlab & Git
  • Resources

Organizational Things

  • new room for tutorials (TBD)
  • warning: programming skills required
  • Master students: email your name, matriculation number, and email address to us
  • got your Gitlab password?
  • students writing Bachelor’s thesis: due date for grade?

Open Source Project Structure

  • src/: source code
    • 01
    • 02
    • project
  • res/: static (external) resource files
  • var/: ever-changing files, e.g. logs
  • etc/: configuration files
  • lib/: external libraries
    • perl/
    • python/
    • java/
  • build/: compiled binaries
  • bin/: executables, e.g. shell script wrapper
  • test/: code for (unit) tests

Git & Gitlab

Why Version Control?

  • collaboration of multiple project members from different places
  • keep track of changes in project
  • roll back changes easily
  • keep different source versions with branching

Why Git?

Benefits

  • decentralized/distributed revision control
    • developers do not need to share a common network
    • work off-line until you want to publish your code
  • widely used
  • fast and easy branching and merging
  • free and open source

Drawbacks

  • steep learning curve
  • (weird command names)
    • maybe at first
    • but then you learn where they come from

Why Gitlab?

  • Easy collaboration: branches, bug reports (issues), bug assignments
  • Easy inspection for instructors
  • Documentation support (markdown, Wiki)
  • Everyone already has an account.

Task 1: Groups

  • form a group
  • 2-3 people
  • mix skill levels

Task 2: Setup Gitlab

  1. Before first use: activate your CIP Gitlab account on CipConf.
  2. CIP Gitlab: https://gitlab.cip.ifi.lmu.de
  3. Create your SSH key (necessary for all your PCs)
  4. Create a new project “ap-[GROUP NAME]”.
  1. Go to Settings -> Members and add your group members with Developer or Master privileges.
  2. Give us (the instructors) access by
    • either making the project public at Project -> Visibility Level
    • or adding us (David Kaumanns, Sebastian Ebert) as new members with Reporter privileges.
  3. Email us the link to the project repository, the group name and your email addresses.

Git Walk Through

Task 3: Exercise

  1. Create the skeleton directory structure.
  2. Create a simple Hello world app in your designated programming language, along with an executable and a basic readme and/or Makefile to compile (if necessary) and run.
  3. Stage, commit, push.
  4. Tag the correct commit hash with name “ex_01”

Idea of Git

http://www.git-scm.com/book/en/v2/Getting-Started-Git-Basics
http://www.git-scm.com/book/en/v2/Getting-Started-Git-Basics

Let’s do it

Commands you Need

  • Clone your project:
    • git clone git@gitlab.cip.ifi.lmu.de:<user name>/<project name>.git
  • Do your changes.
  • Stage your changes (i.e. tell Git that they exist):
    • git add <file name|patterns>
  • Commit your changes to your local repository:
    • git commit -am "initial commit"
      • -a (--all): automatically stage files that have been modified and deleted (only those Git already knows).
      • -m (--message): use an inline commit message.
  • Push your changes to the remote repository:
    • git push
      • For first push: git push -u origin master
  • Do more changes. Repeat: stage, commit, push.
  • Do fresh pulls regularly:
    • git pull
  • Check your status:
    • git status
  • Check differences
    • git diff
      • if problems with color occur: git config --global core.pager "less -r"
  • Review previous commit
    • git show
  • Use an alias for nicely formatted logs:
    • git config --global alias.lga "log --pretty=format:'%C(auto)%h %C(110)%ad%Creset%C(auto)%d %s' --graph --date=short --all"
    • git lga

Branching

Wittfind Web branches
Wittfind Web branches
  • Create new branch:
    • git branch awesome-feature
  • Switch to new branch:
    • git checkout awesome-feature
      • (Shorthand for last two steps: git checkout -b awesome-feature)

Ready to merge your new feature into the master branch?

  • Switch to the master branch:
    • git checkout master
  • Merge your branch into the current one (master):
    • git merge awesome-feature
  • Delete the deprecated branch:
    • git branch -d awesome-feature

Words to remember

  • HEAD: pointer to your current position in the history
  • ORIGIN: original remote repository
  • master: the (hopefully) stable master branch
  • upstream: usually means the remote repository, i.e., where the code is coming from (“up the stream”) or where you push to and pull from
  • fast-forward: moving the HEAD pointer forward in history
  • .gitignore: list of stuff to ignore

Great Git tutorials

Resources

Which resources do you know?
Which resources do you know?

Lexicons

Treebanks

(S
    (NP
        (NNP John)
    )
    (VP
        (VPZ loves)
        (NP
            (NNP Mary)
        )
    )
    (...)
)

Knowledge bases & ontologies

Parallel text corpora

Questions & answers

Collocations & NGrams

Pretrained models & representations

Text corpora

Wikipedia

Assignment

Exercise 01 - Hello CIS

  1. Create a course project repository in CIP Gitlab (see instructions above). Add your group members and us.
  2. Create the skeleton directory structure.
  3. Create a simple Hello world app in your designated programming language, along with an executable and a basic readme and/or Makefile to compile (if necessary) and run.
  4. Stage, commit, push.
  5. Tag the correct commit hash with name “ex_01”

Due: Thursday April 23, 2015, 16:00, i.e., the tag must point to a commit earlier than the deadline

Have fun