WARNING: Work in progress
= Introduction =
GIT is a Version Control System (VCS) for source code created by Linus Torvald (the creator of Linux). It allows to share and collaborate on code efficiently. It somewhat has a diffucult barrier to entry because it's packed with feature. However you can learn a few basic terms and command to use it in an easy way.
= Distributed =
In opposition ot other VCS (Subversion for instance), GIT is distributed. It means there's no central server and everything you do is happening on your local machine. It also means you can work on your code locally without being connected to the internet and syncronize with a remote server later.
= Vocabulary =
Here's a list of usual terms you will enconter in the guide, you can refer to it later.
- Repository / History: The git history represents your code at different stages in its development, all of this is a repository
- Commit: This is a set of patches bundled together with an author name and email at a specific date. The history is composed of a sequence of commits. Each commit has a parent commit forming a immutable history.
- Branch: Like a tree branch, a sequence of commits may have diverged from the main (master) branch, usually to develop a new feature that will be merged back to the main branch
- Merge: Reconcile two branches by creating a merge commit and resolving potential conflicts (the same line in a file have been edited in both branches for instance)
- Local: A repository on your machine is a local repository
- Remote: A repository on a server (c4science, github, ...) is a remote repository. A local repository can be bound to multiple remotes at the same time
- Working copy: These are the files you see in your machine, it represents the states of your repository at a certain point in time (a commit) and space (a branch)
- Index / Staging area: This is a remporary place where you add changes to be commited. Typically using `git add <file>`. It's usefull to separate the working copy and the staging area in case you don't want to commit every changes
= Basic operations =
{F5056499, size=full}
The usual workflow when using git consist of the following sequence of commands:
```
git clone <URI>
git add <file>
git commit -m "commit message"
git pull
git push
```
Let's break down every command.
== git clone ==
This retrieve a remote repository on your machine, downloading the complete history of every branches locally. It's actually a wrapper for other commands:
- git fetch # gets all the changes on the remote to a local history
- git checkout HEAD # create a working copy of the HEAD (usually the master branch)
== git add ==
= References =
- https://git-scm.com/book/en/v2/Getting-Started-Git-Basics