====== Git Lightning Talk ======
What is Git About?
- Version Control
- Collaboration
===== 0. Setting Up Git =====
If you have never used git before you will need to tell it about yourself. This is used to record who made changes:
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
===== 1. Version Control =====
Gradually modify a project* and create "save points" (commits) each with their own message. Allows you to return to a previously working version, or recover work that was deleted.
Just on your laptop you can create a Git repository:
$ git init MyProject
$ cd MyProject
You then need to add some files to this directory and tell Git that you want to track them:
$ editor project.txt
$ git status
On branch master
Initial commit
Untracked files:
(use "git add ..." to include in what will be committed)
project.txt
nothing added to commit but untracked files present (use "git add" to track)
$ git add project.txt
$ git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached ..." to unstage)
new file: project.txt
Running ''git status'' will tell you what has changed and what you need to do next. We are now ready to create a commit. This will open up your editor and allow you to enter a message about this commit. Try to be informative though this is often hard.
$ git commit
If you know that you want to write a shorter message it is normally sufficient to add the comment directly on the command line:
$ git commit -m "Initial commit of myproject."
To see the history of your project you can run:
$ git log
commit 9c75aa5e480a9ca8c3ae9f5197ddb074f72b5058
Author: Paul Hopkins
Date: Fri Nov 10 09:49:21 2017 +0000
Initial commit of myproject.
Notice that commits are represented by a hash, which can be shortened e.g. ''9c75aa''. Git cannot use a simple numbering system (e.g. Version 0001, 0002,...,) due to its distributed nature. Commit IDs are used by git commands to refer to specific commits.
You can continue to edit your project, and create new commits. Each time you need to tell git which files you want to add to this commit. This may be because you may have noticed another bug while working and want to commit that in separation. ''git status'' will help you see what has changed and what you are ready to commit.
==== Interactive Tutorial ====
GitHub provides a web based interactive tutorial which should lead you through the basics of git, and starting to use more advanced topics. Please start here and complete it at your leisure.
* [[https://try.github.io]]
===== Links =====
* [[https://git-scm.com]] The Git Homepage.
* [[https://github.com]] GitHub is the most successful Git hosting service.
* [[https://about.gitlab.com]] GitLab is an alternative that also open sources their web service.
* [[http://git.ligo.org]] The LIGO GitLab instance.
* [[https://youtu.be/CDeG4S-mJts]] Hitler Reacts to Git.