# Getting started

## On this page:

1. [Installation & Guide](https://github.com/git-guides/install-git)
2. [General Idea & Basics](#general-idea-and-basics)
3. [GitHub](#github-remote-repositories)

## Installation & Guide

Follow the directions here to install git:

{% embed url="<https://github.com/git-guides/install-git>" %}

## General Idea & Basics

Git lets you use branches to test new features/code while keeping a clean record on the main master branch. This functionality is great: if the experimental feature is unsuccessful, it doesn't effect the copy on the master branch; otherwise, if successful, it can be merged back into the master branch.&#x20;

![https://nvie.com/posts/a-successful-git-branching-model/](https://3071976149-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIB5AI4iyB7O4uln8Ob%2F-MNAWOMgDsRUyezWxtOJ%2F-MNAYJp7MewOTElqPy4w%2Fimage.png?alt=media\&token=958defd8-436a-416d-a974-4f6e5acd18d1)

To create a local git repository, run `git init` in the desired directory. To add or update files in the local repo, first use `git add <filename>` to add individual files or  `git add .` to add all files (excluding those in [.gitignore](#gitignore-file)). This moves the updated files into the staging area and you can check the status using `git status`. Then, commit these changes to the local repo using `git commit -m <message>` and you can check commit history with `git log`.&#x20;

To collaborate, you would want to set up a remote repository on [GitHub](#github-remote-repositories). To update the files on the remote repo, use `git push`. To update your local repo (*e.g.* when a collaborator has edited something in the remote repo), use `git pull`. Be sure to use `git pull` before `git push`, and if there is a conflict, you may need to merge the code before pushing onto the remote repo.

![https://medium.com/@gagansuneja](https://3071976149-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MIB5AI4iyB7O4uln8Ob%2F-MMr39hLfzrTES9fMOUk%2F-MMr4nm_dfkF-ohr73WH%2Fimage.png?alt=media\&token=81d95caf-f3d5-47b2-8b1a-c83d67809a30)

### .gitignore file

List the directories and files (e.g. big data files, private info/keys, virtual environment directory, etc.) that you don't want to track with git in a file named *.gitignore*.

## GitHub: Remote Repositories

GitHub is really popular for hosting remote Git repositories. Create an account on GitHub:&#x20;

{% embed url="<https://github.com>" %}
