Git & GitHub

Ensure Linux is up to date

sudo apt-get update && sudo apt-get full-upgrade -y

Install into Linux

--> check first if it is already installed

git --version

--> install git

sudo apt install -y git

Connecting to GitHub Options

ssh-keygen -t ed25519 -C "mr.coxall@mths.ca"
cat ~/.ssh/id_ed25519.pub

--> paste in the SSH displayed from above into GitHub "SSH and GPG keys"

ssh -T git@github.com

2. GitHub Token

--> ensure gh cli is installed 

sudo apt install gh

--> authentic with GitHub

gh auth login
? What account do you want to log into? GitHub.com

? What is your preferred protocol for Git operations? HTTPS
? Authenticate Git with your GitHub credentials? (Y/n) Y

? How would you like to authenticate GitHub CLI?  [Use arrows to move, type to filter]
  > Login with web browser

NOTE: DO NOT try to copy the code in your terminal; you will kill the gh session and need to start again!
!First copy your one-time code: FFFF-FFFF

Press Enter to open github.com in your browser... 

! Failed opening a web browser at https://github.com/login/device

  exec: "xdg-open,x-www-browser,www-browser,wslview": executable file not found in $PATH

  Please try entering the URL in your browser manually

✓ Authentication complete.

- gh config set -h github.com git_protocol https

✓ Configured git protocol

✓ Logged in as Mr-Coxall

Configure, after connecting

git config --global user.email "mr.coxall@mths.ca"
git config --global user.name "Mr Coxall"
git config --global init.defaultBranch main
git config --global pull.rebase false

git config --global fetch.prune true


see here: https://spin.atomicobject.com/2020/05/05/git-configurations-default/

Cloning GitHub Repo into your development environment

--> if connected by GitHub SSH key

git clone git@github.com:mr-coxall/repo_name.git

for example:
    git clone git@github.com:mr-coxall/ICS4U-Intro-02-TypeScript.git

--> if connected by GitHub CLI

gh repo clone mr-coxall/repo_name

for example:
    gh repo clone mr-coxall/ICS4U-Intro-02-TypeScript

Committing and Pushing back to GitHub

git add -A
git commit -m "commit message"
git push origin main

Getting changes you make in GitHub to your code base

git pull origin main

GitHub Action for Linting

##################################################

# Run Mr Coxall's Super Linter against code base #

##################################################


---

name: Mr Coxall's Super Linter


on: [push, pull_request]


jobs:

  run-linters:

    name: Mr Coxall's Super Linter

    runs-on: ubuntu-latest


    steps:

      - name: Check out Git repository 🚦

        uses: actions/checkout@main


      - name: Run GitHub Super Linter 🚀

        uses: mr-coxall/super-linter@master

        env:

          VALIDATE_ALL_CODEBASE: true

          LINTER_RULES_PATH: /

          VALIDATE_CLANG_FORMAT: false

          VALIDATE_JAVASCRIPT_STANDARD: false

          VALIDATE_GOOGLE_JAVA_FORMAT: false

          VALIDATE_PYTHON_FLAKE8: false

          VALIDATE_GITLEAKS: false # for secrets detection

          VALIDATE_JSON: false

          VALIDATE_JSCPD: false # for copy and paste detection

          DEFAULT_BRANCH: main

          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Then place the following code in a README.md file in your root folder

Make sure you replace <OWNER> with your Github Account name, and <REPOSITORY> with the name of your project!

[![Mr Coxall's Super Linter](https://github.com/<OWNER>/<REPOSITORY>/workflows/Mr%20Coxall's%20Super%20Linter/badge.svg)](https://github.com/<OWNER>/<REPOSITORY>/actions/)


If the root of the repo is your website then:

This site can be found at: [https://<OWNER>.github.io/<REPOSITORY>](https://<OWNER>.github.io/<REPOSITORY>)