Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
- a very handy [cheat sheet](https://gitea.86thumbs.net/waldek/LinuxSysAdminsDoc/raw/branch/master/Git/SWTM-2088_Atlassian-Git-Cheatsheet.pdf) in pdf outlines the basic Git commands to help you learn git, as well as more advanced concepts such as Git branches, remote repositories, undoing changes, and much much more
- the main git [documentation](https://git-scm.com/book/en/v2) is an excellent reference manual
The diagram below outlines the main gt commands and how they relate to the version control system.
In our classes the **local** is the repository on your own computer and the **remote** is the corresponding repository you create on our [gitea](https://gitea.86thumbs.net/) server.
Nothing is stopping you from hosting your own gitea server or pushing your local repository to a third party server such as [gitlab](https://about.gitlab.com/).
Clone repo located at **\<repo>** onto local machine. Original repo can be located on the local file system or on a remote machine via **HTTPS** or **SSH**.
Throughout the classes you'll first clone via HTTPS but once we'll learn about [RSA](https://en.wikipedia.org/wiki/RSA_(cryptosystem)) you'll be able to clone, push and pull over SSH.
```bash
git clone $REPOSITORY_URL
```
## Git config --global name & email
Before you can use git you **need** to identity yourself.
Git uses this information in each commit so we can keep track of **who** did **what****when**.
Name and email are **required** configuration settings but there are a lot more settings you can change to your liking.
For example you can set the user interface to have colors by default by setting the following configuration.
```bash
git config --global color.ui auto
```
All of the possible configuration settings can be seen my running:
```bash
man git-config
```
Additionally you can read up on all of these settings a bit more on the [documentation page](https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Configuration) online.
Delete the file from project and stage the removal for commit.
Do keep in mind that this removes the file from the next commit but the file will still exist in the previous commits.This makes it very difficult to *lose* files for ever.
```bash
git rm $FILENAME
```
Change an existing file path and stage the move.
```bash
git mv $OLDPATH $NEWPATH
```
Show all commit logs with indication of any paths that moved.
```bash
git log --stat -M
```
If you ever *lose* a file you can use the following command to locate when files got deleted.
Remember that *when* is tied to a commit.
Once you find the commit you can check out only that file to bring it back to your working directory.
Tig is an additional program that can be used to inspect and visualize the commit history.
It uses the underlying Git commands to present the user with various views, such as summarized commit log and showing the commit with the log message, diffstat, and the diff.
As it's a command line program wherein you can navigate, select, etc, we can call it a [tui](https://itsfoss.com/gui-cli-tui/).
It comes installed by default with git in windows but on debian you have to install it manually.