<commit_before># GIT CHEAT SHEET

`git` _is a free and open source DVCS (Distributed Version Control System)._

[GitHub Webpage](https://jeffdecola.github.io/my-cheat-sheets/)

## INSTALL

For Linux,

```bash
sudo apt install git
```

For Windows,

There are two main options,

Option 1. Stand alone, git for windows app (completely independent from
bash on ubuntu on windows)

```bash
https://git-scm.com/downloads
```

Option 2. Open bash on ubuntu on windows and install like linux above.
I'm not a huge fan of bash on windows.

## CONFIGURE FOR LINUX

I also like to add the hostname/machine name so I know where it came from,

```bash
git config --global user.name "<NAME> (HOSTNAME/MACHINE NAME)"
git config --global user.email YOUREMAIL
git config --global core.editor nano
```

Check configuration,

```bash
git config --list
```

## CONFIGURE FOR WINDOWS

Same as above but may also have to add permissions to ci scripts.

e.g.

```bash
git update-index --chmod=+x readme-github-pages.sh
```

## HTTPS ACCESS

Generate a personal access token for your machines .netrc
file at github.com.

Creating a .netrc file and be placing this token in
login field as follows,


```bash
nano ~/.netrc
```

Add,

```bash
machine github.com
login {TOKEN FROM GITHUB}
```

## SSH KEY

Generate public and private key for Ubuntu,

```bash
ssh-keygen -t rsa -b 4096 -C "phrase"
```

Now add key,

```bash
ssh-add ~/.ssh/id_rsa
```

Copy your public ssh key,

```bash
cat ~/.ssh/id_rsa.pub
```

Goto GitHub.com and paste your public ssh key (settings -> ssh keys)

Check the fingerprint at github against your local public key.
You may not need the md5 option,

```bash
ssh-keygen -E md5 -lf ~/.ssh/id_rsa.pub
```

To connect to GitHub use,

```bash
ssh -T git@github.com
```

If you want to use a particular public key file,

```bash
ssh -i ~/.ssh/id_rsa.pub git@github.com
```

Force git to use ssh on your local repo, rather the https,

```bash
git remote set-url origin git@github.com:JeffDeCola/REPONAME.git
```

Check ssh settings,

```bash
git config --list
```

Hence,

```bash
remote.origin.url=https://github.com/JeffDeCola/my-cheat-sheets.git
```

Was changed to ssh method,

```bash
remote.origin.url=<EMAIL>@github.com:JeffDeCola/my-cheat-sheets.git
```

## WORKFLOW

The Git Workflow.

![IMAGE - my-cheat-sheets concourse ci piepline - IMAGE](docs/pics/GIT-Repo-Workflow-Diagram.jpg)

### CLONE

Via http,<commit_msg>minor -  fixed .jpg link<commit_after># GIT CHEAT SHEET

`git` _is a free and open source DVCS (Distributed Version Control System)._

[GitHub Webpage](https://jeffdecola.github.io/my-cheat-sheets/)

## INSTALL

For Linux,

```bash
sudo apt install git
```

For Windows,

There are two main options,

Option 1. Stand alone, git for windows app (completely independent from
bash on ubuntu on windows)

```bash
https://git-scm.com/downloads
```

Option 2. Open bash on ubuntu on windows and install like linux above.
I'm not a huge fan of bash on windows.

## CONFIGURE FOR LINUX

I also like to add the hostname/machine name so I know where it came from,

```bash
git config --global user.name "<NAME> (HOSTNAME/MACHINE NAME)"
git config --global user.email YOUREMAIL
git config --global core.editor nano
```

Check configuration,

```bash
git config --list
```

## CONFIGURE FOR WINDOWS

Same as above but may also have to add permissions to ci scripts.

e.g.

```bash
git update-index --chmod=+x readme-github-pages.sh
```

## HTTPS ACCESS

Generate a personal access token for your machines .netrc
file at github.com.

Creating a .netrc file and be placing this token in
login field as follows,


```bash
nano ~/.netrc
```

Add,

```bash
machine github.com
login {TOKEN FROM GITHUB}
```

## SSH KEY

Generate public and private key for Ubuntu,

```bash
ssh-keygen -t rsa -b 4096 -C "phrase"
```

Now add key,

```bash
ssh-add ~/.ssh/id_rsa
```

Copy your public ssh key,

```bash
cat ~/.ssh/id_rsa.pub
```

Goto GitHub.com and paste your public ssh key (settings -> ssh keys)

Check the fingerprint at github against your local public key.
You may not need the md5 option,

```bash
ssh-keygen -E md5 -lf ~/.ssh/id_rsa.pub
```

To connect to GitHub use,

```bash
ssh -T git@github.com
```

If you want to use a particular public key file,

```bash
ssh -i ~/.ssh/id_rsa.pub git@github.com
```

Force git to use ssh on your local repo, rather the https,

```bash
git remote set-url origin git@github.com:JeffDeCola/REPONAME.git
```

Check ssh settings,

```bash
git config --list
```

Hence,

```bash
remote.origin.url=https://github.com/JeffDeCola/my-cheat-sheets.git
```

Was changed to ssh method,

```bash
remote.origin.url=git@github.com:JeffDeCola/my-cheat-sheets.git
```

## WORKFLOW

The Git Workflow.

![IMAGE - GIT Repo Workflow Diagram - IMAGE](../docs/pics/GIT-Repo-Workflow-Diagram.jpg)

### CLONE

Via http,
{'fraction_non_alphanumeric': 0.12453531598513011, 'fraction_numerical': 0.003304419661296985, 'mean_word_length': 3.7714285714285714, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 8, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 7, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1327699', 'n_tokens_mistral': 1870, 'n_tokens_neox': 1654, 'n_words': 628}