Skip to content

Latest commit

 

History

History
328 lines (220 loc) · 12.4 KB

File metadata and controls

328 lines (220 loc) · 12.4 KB

GitHub

NOT PORTED YET

GitHub Skills Training

https://skills.github.com/

Access

Personal Access Tokens

Generate your token here:

https://github.com/settings/tokens

Configure SSH Keys

Generate an SSH key:

ssh-keygen

(see SSH page for more options)

Then upload the public key here:

https://github.com/settings/keys

GitHub SSH Key SSO Authorization

If you're using SSH keys to git clone in a company using GitHub SSO authentication then you will need to authorize your SSH keys for each organization in order to be able to use them.

On this page listing your SSH keys:

https://github.com/settings/keys

On the right of each key, click the Configure SSO drop-down and then next to the organizations you're a member of click Authorize.

https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating-with-saml-single-sign-on/authorizing-an-ssh-key-for-use-with-saml-single-sign-on

Git Clone over HTTPS using API Token

Cloning with HTTPS then becomes:

git clone "https://GITHUB_TOKEN@github.com/$ORG/$REPO.git"

or better using a credential helper...

Credential Helper

Taken from my .gitconfig:

[credential "https://github.com"]
    # without the "sleep 1" the Git command may miss catching the output and hang instead
    helper = "!f() { sleep 1; echo \"username=${GITHUB_USER}\"; echo \"password=${GH_TOKEN:-${GITHUB_TOKEN}}\"; }; f"

[credential "https://gist.github.com"]
    helper = "!f() { sleep 1; echo \"username=${GITHUB_USER}\"; echo \"password=${GH_TOKEN:-${GITHUB_TOKEN}}\"; }; f"
git clone "https://github.com/$ORG/$REPO.git"

If you get a 401 or 403 authentication or authorization error, you can check Git debug output by setting:

export GIT_CURL_VERBOSE=1

Pull Requests

Use Pull Requests to track changes and get peer review and approval.

Keep PRs as small and atomic as possible - people's eyes will glaze over on big PRs resulting in lgtm approvals out of fatigue, missing bad code or bugs into the repo and defeating the quality control of peer review.

The more lines in a PR, there more likely your colleagues will miss something.

1000 line GitHub PR

Hopefully your more thorough 'rainman' coding bro comes along and revokes the approval.

Review 1 vs Reviewer 2

CodeOwners

HariSekhon/Templates - .github/CODEOWNERS

Enforce Pull Request reviews to all or given paths in the repo to this list of users or teams.

Auto-notifies these code owners requesting reviews when pull requests changing their files are raised.

CodeOwners Gotcha - Secret Teams

When listing GitHub teams in the .github/CODEOWNERS file, the team must not be set to Secret otherwise it won't be respected, on top of it requiring Write access to the repo.

GitHub Profile Page

Create a GitHub repo with the same name as your GitHub profile username and in it create a README.md file which will be automatically displayed as your GitHub profile home page.

You can do anything you normally can in Markdown - links, formatting, using HTML and embedding 3rd party tools like:

URL Description
https://shields.io Badges
https://komarev.com/ghpvc/ Profile hits counter
:octocat: anuraghazra/github-readme-stats Profile Stats or GitHub repos to list more repos than that annoying arbitrary 6 repo pin limitation

See my GitHub Home Profile page:

https://github.com/HariSekhon

which comes from this repo:

:octocat: HariSekhon/HariSekhon

GitLab uses this too but it puts a Read more link instead of displaying the whole page like GitHub.

Use Permalink URL References for Documentation or Support Issues

When referencing GitHub lines or HTML anchors in Documentation or support issues, use a permalink URL instead of the default branch link, which can change and misdirect your line number or anchor references.

A permalink uses the commit hashref so that it always goes to that fixed line or anchor in history.

Press y on a page while browsing GitHub.com to change the current branch URL to a permalink hashref commit URL.

Analyze GitHub Repos

OpenHub

(formerly Black Duck Open Hub)

https://openhub.net/

SonarCloud

Gives lines of code and ode quality metrics like maintainability, security vulnerabilities, and technical debt.

You can see badges for this across my public GitHub repos.

RepoGraph

https://repograph.io/

OctoInsight

https://octoinsight.io/

GitHub Linguist

gem install github-linguist
linguist /path/to/repo

Cloc - Count Lines of Code

:octocat: AlDanial/cloc

Counts lines of code vs comments vs blanks.

Install on Mac:

brew install cloc

Install on Debian / Ubuntu:

sudo apt install cloc

Run it against a directory of code to count the lines of code:

cloc /path/to/git/checkout
cloc ~/github/bash-tools
github.com/AlDanial/cloc v 2.02  T=3.16 s (1084.1 files/s, 260706.2 lines/s)
---------------------------------------------------------------------------------
Language                       files          blank        comment           code
---------------------------------------------------------------------------------
JSON                              33              5              0         528324
Bourne Shell                    1594          26338          38702          70205
YAML                             885           6568          29712          41929
HCL                              192           3965           4595          16567
Markdown                          70           3964            321          13016
Text                              56            323              0           5004
SQL                              233            862           5533           4182
Groovy                           140            924           4122           3933
Bourne Again Shell                97           1219           3904           2337
XML                               24              9              9           1490
make                              21            352            373           1320
INI                               12            148              0            804
Maven                              1             62             68            342
Python                             7            108            401            235
Perl                               5             67             74            230
m4                                 5             55              3            216
Go                                 1             12             20             97
Ruby                              13             16            247             81
Dockerfile                         1             66            181             78
Properties                         8             54            133             77
Java                               4             31             54             63
Scala                              4             27             69             42
Gradle                             2             13             60             39
Jinja Template                     1              2              0             33
JavaScript                         3             31            152             30
Expect                             2              5             15             22
Puppet                             3              7             61             20
ASP                                1              4              1             11
SVG                                6              0              0              6
C                                  1              3              6              3
zsh                                1              1             13              3
PHP                                1              3              6              2
DOS Batch                          1              2              5              1
Visual Basic Script                1              3              5              1
Pig Latin                          1              2             14              0
---------------------------------------------------------------------------------
SUM:                            3430          45251          88859         690743
---------------------------------------------------------------------------------

Script in DevOps-Bash-tools to count lines across all public original GitHub repos:

github_public_lines_of_code.sh

Memes

O'Reilly - Choosing Based on GitHub Stars

Baby Yoda Gets GitHub Stars

Waking up to 2000 More Stars

GitHub vs Sleep

GitHub vs Sleep

Ransacking Someone's GitHub

Ransacking Someone's GitHub

Met Wife in GitHub Issues Thread

Met Wife in GitHub Issues Thread

The Lone Wolf Developer

Aren't you lucky this isn't me...

Lone Wolf Developer

The Hungry Developer

Hungry Developer

Rutting Season

Rutting Season

Disclaimer: seriously, don't get married, you can't control the forking today.

Approving Own Pull Requests

Don't approve your own pull requests.

Me Approving My Own Pull Requests