Modeling and Simulating Social Systems with MATLAB...2016-10-172014-03-03 Modeling and Simulating...

Preview:

Citation preview

2016-10-17ETH Zürich

Modeling and Simulating Social Systems with MATLAB

Lecture 4 – Git

Chair of Computational Social Science

Olivia Woolley, Lloyd Sanders, Dirk Helbing

2

Revision Control

Revision (or version) control systems are software aimed at managing changes to files (such as source code files)

Version control software: Traditional/centralized: CVS, Subversion (SVN)

Modern/distributed: Bazaar, Mercurial, Git

We will use Git for managing the research proposals, source code, and final reports

2014-03-03 Modeling and Simulating Social Systems with MATLAB 32016-10-17

Distributed revision control / source code management

Initially designed and developed by Linus Torvalds

Git repositories (“code bases”) consist of a history of commits

(“changes”)

Every (local) instance of a repository has the complete history

Supported by popular hosting sites such as GitHub and Bitbucket

2014-03-03 Modeling and Simulating Social Systems with MATLAB 42016-10-17 4

Collaboration and Branches

2014-03-03 Modeling and Simulating Social Systems with MATLAB 52016-10-17 5

Course repositories

The GitHub organization for the course:https://github.com/msssm

Links to projects of previous semesters:https://github.com/msssm/interesting_projects/wiki

Template for project repository:https://github.com/msssm/project_template

2014-03-03 Modeling and Simulating Social Systems with MATLAB 62016-10-17 6

Using Git

On the command line, Git is used by calling the git command

There are many graphical user interfaces for different operating systems

There are Git plugins for development environments such as Eclipse

2014-03-03 Modeling and Simulating Social Systems with MATLAB 72016-10-17 7

Using Git: Introduction

Introduce yourself to Git:

$ git config --global user.name "Your Name" $ git config --global user.email i@me.com

2014-03-03 Modeling and Simulating Social Systems with MATLAB 82016-10-17 8

Using Git: Initialization

To initialize an empty repository, you can use the command git init

Initialize your first Git repository:

$ cd /path/to/code/dir/$ git init

2014-03-03 Modeling and Simulating Social Systems with MATLAB 92016-10-17

2014-03-03 Modeling and Simulating Social Systems with MATLAB 102016-10-17 10

Using Git: Tracking and Committing

Tell Git which files you would like to include:

Take a snapshot (commit) of all tracked files:

$ git add file1 file2$ git add .

$ git commit –m “This is my first commit”

2014-03-03 Modeling and Simulating Social Systems with MATLAB 112016-10-17 11

Using Git: Status and Diff

Show the status of the repository:

$ git status

Inspect the differences:

$ git diff

2014-03-03 Modeling and Simulating Social Systems with MATLAB 122016-10-17 12

Using Git: Some Recommendations

Commit often

Use meaningful commit messages

New files are not automatically indexed, must be added

Be careful with respect to which files to add

Do not add very large files (compress videos and upload them only in the end)

Write a .gitignore file or use git ignore for files that you never want to commit (e.g. big datasets)

2014-03-03 Modeling and Simulating Social Systems with MATLAB 132016-10-17 13

Using Git: GitHub

If you are not registered yet, please do so (every

student should have an account):

https://github.com/

Some initial configuration is required. 1. Copy your SSH public key to your github account

(optional)

2. Fork the “report_template” repository to “my_repo”

3. Configure it (rename, add team members)

4. Clone “my_repo” on your machine

5. Push your first commit

2014-03-03 Modeling and Simulating Social Systems with MATLAB 142016-10-17 14

Using Git: SSH Keys (optional)

An SSH public key is a certificate of your identity

If you upload your SSH public key to your Github

account, you don’t have to type in username and

password every time you connect to GitHub

https://help.github.com/articles/generating-ssh-keys

https://help.github.com/articles/set-up-git

2014-03-03 Modeling and Simulating Social Systems with MATLAB 152016-10-17 15

Needs to be performed by only one group member

(one repository per group)

Click the Fork button at the top of this page:

https://github.com/msssm/project_template

In the Settings of the forked project:

Rename to a meaningful name

Add your team members (collaborators)

Using Git: Fork and Configuration

2014-03-03 Modeling and Simulating Social Systems with MATLAB 162016-10-17

Using Git: Clone Project Template

Make a local copy of your new repository

$ git clone git@github.com:USERNAME/PROJECT.git

16

2014-03-03 Modeling and Simulating Social Systems with MATLAB 172016-10-17 17

Check that your local copy of the repo points to the correct online repository (your fork)

$ git remote -vorigin git@github.com:USERNAME/PROJECT.git (fetch)origin git@github.com:USERNAME/PROJECT.git (push)

Using Git: Remote Repos

2014-03-03 Modeling and Simulating Social Systems with MATLAB 182016-10-17 18

Using Git: Upload Commits

Write your research plan inside the README file

When you are happy :

$ git add README.md

$ git commit –m “Research Plan done”

$ git push –u origin master

2014-03-03 Modeling and Simulating Social Systems with MATLAB 192016-10-17 19

Using Git: Let us know

Send the link to your project repository on

GitHub to olivia.woolley@gess.ethz.ch and

lloyd.sanders@gess.ethz.ch

2014-03-03 Modeling and Simulating Social Systems with MATLAB 202016-10-17 20

References

Git Home Page: http://git-scm.com/

Git General Info: http://git-scm.com/about

Github Home Page: https://github.com/

GitX (a gui for OS X): http://gitx.frim.nl/

Git in 5 minutes: http://www.fiveminutes.eu/a-case-for-git/

Git Book http://book.git-scm.com/

Git: creating a repo http://help.github.com/create-a-repo/

Git: working with remotes http://help.github.com/remotes/

EGit plugin for Eclipse: http://www.eclipse.org/egit/

Markdown: http://daringfireball.net/projects/markdown/syntax

Recommended