851-0585-04L – Modeling and Simulating Social Systems with MATLAB Lecture 2 – Let’s GIT started: local operations Karsten Donnay and Stefano Balietti Chair of Sociology, in particular of Modeling and Simulation © ETH Zürich | 2011-10-10 Let’s Git Started: local operations In this mini tutorial you will receive the basic knowledge to work with GIT in your local machine GIT is a great tool when combined with an online repository, but this is the topic of next week. 2011-10-10 K. Donnay & S. Balietti / [email protected] [email protected] 2 Let’s Git Started: local operations GIT is free, open source software. http://git-scm.com/ Works from GUI and from terminal (command-line) On the Lab machines you can launch it with: 2011-10-10 GIT Bash (Windows) git (Linux – command line only) K. Donnay & S. Balietti / [email protected] [email protected] 3 Let’s Git Started: command line ?!?? Don‘t panic! You need just three commands: (but you can learn more...) 2011-10-10 Change directory: cd List files in a directory: ls Create a new directory: mkdir <name_of_dir> K. Donnay & S. Balietti / [email protected] [email protected] 4 Let’s Git Started: initialization Open a terminal or GIT Bash. Set the language to English (if you like) $ export LANG=en_us Browse to the directory with the project template files. Initialize your first GIT repository $ cd /path/to/your/files/ $ git init 2011-10-10 K. Donnay & S. Balietti / [email protected] [email protected] 5 Let’s Git Started: introduction Introduce yourself to GIT. 2011-10-10 K. Donnay & S. Balietti / [email protected] [email protected] 6 Let’s Git Started: introduction Introduce yourself to GIT. $ git config --global user.name "Your Name" $ git config --global user.email [email protected] 2011-10-10 K. Donnay & S. Balietti / [email protected] [email protected] 7 Let’s Git Started: give GIT tasks Tell GIT which files you would like to track for changes. $ git add file1 file2 $ git add . Take a snapshot (commit) of all tracked files $ git commit –m “This is my first commit” 2011-10-10 K. Donnay & S. Balietti / [email protected] [email protected] 8 Let’s Git Started: do your job… Do any modification to the content of the files. Get the update of the status of the repository $ git status Visualize the differences in the terminal. $ git diff Visualize the differences in a GUI client $ gitk ; git gui ; gitx (for MAC) 2011-10-10 K. Donnay & S. Balietti / [email protected] [email protected] 9 Some hints how to use GIT for your code Commit often. Use appropriate commit messages. Do not rename the file names manually (use git mv) New files are not automatically indexed, must be added. Careful with git add . Rather choose the files: git add file1 Write a .gitignore file or use git ignore for files that you never want to commit (e.g. big datasets) 2011-10-10 K. Donnay & S. Balietti / [email protected] [email protected] 10 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/ 2011-10-10 K. Donnay & S. Balietti / [email protected] [email protected] 11
© Copyright 2026 Paperzz