Introduction_to_Git_and_GitHub/module3.ipynb
2025-03-07 23:12:10 +03:00

1740 lines
80 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Basic Interaction with GitHub\n",
"\n",
"This reading contains the code used in the instructional videos from [**Basic interaction with GitHub**<svg aria-labelledby=\"cds-react-aria3604314262-:r3dn:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r3dn:\"><title id=\"cds-react-aria3604314262-:r3dn:-title\">Opens in a new tab</title></svg>](https://www.coursera.org/learn/introduction-git-github/lecture/4Fl6n/basic-interaction-with-github)**.** \n",
"\n",
"## Introduction\n",
"\n",
"This follow-along reading is organized to match the content in the video that follows. It contains the same code shown in the next video. These code blocks will provide you with the opportunity to see how the code is written, allow you to practice running it, and can be used as a reference to refer back to. \n",
"\n",
"You can follow along in the reading as the instructor discusses the code or review the code after watching the video.\n",
"\n",
"```bash\n",
"git clone https://github.com/redquinoa/health\\-checks.git\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Cloning into 'health-checks'...\n",
"\n",
"Username for 'https://github.com': redquinoa\n",
"\n",
"Password for 'https://redquinoa@github.com': \n",
"\n",
"remote: Enumerating objects: 3, done.\n",
"\n",
"remote: Counting objects: 100% (3/3), done.\n",
"\n",
"remote: Compressing objects: 100% (2/2), done.\n",
"\n",
"remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0\n",
"\n",
"Unpacking objects: 100% (3/3), done.\n",
"\n",
"```bash\n",
"cd health\\-checks/\n",
"\n",
"ls \\-l\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"total 4\n",
"\n",
"\\-rw-rw-r-- 1 user user 62 Jan  6 14:06 README.md\n",
"\n",
"```bash\n",
"atom README.md\n",
"\n",
"# health-checks\n",
"\n",
"Scripts that check the health of my computers\n",
"\n",
"This repo will be populated with lots of fancy checks. \n",
"```\n",
"\n",
"```bash\n",
"git commit \\-a \\-m \"Add one more line to README.md\"\n",
"```\n",
"\n",
"**Code output:**\n",
"\n",
"\\[master 807cb50\\] Add one more line to README.md\n",
"\n",
" 1 file changed, 2 insertions(+)\n",
"\n",
"```bash\n",
"git push\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Username for 'https://github.com': redquinoa\n",
"\n",
"Password for 'https://redquinoa@github.com': \n",
"\n",
"Enumerating objects: 5, done.\n",
"\n",
"Counting objects: 100% (5/5), done.\n",
"\n",
"Delta compression using up to 4 threads\n",
"\n",
"Compressing objects: 100% (2/2), done.\n",
"\n",
"Writing objects: 100% (3/3), 347 bytes | 347.00 KiB/s, done.\n",
"\n",
"Total 3 (delta 0), reused 0 (delta 0)\n",
"\n",
"To https://github.com/redquinoa/health-checks.git\n",
"\n",
"   3d9f86c..807cb50  master -> master\n",
"\n",
"```bash\n",
"git config \\--global credential.helper cache\n",
"```\n",
"\n",
"```bash\n",
"git pull\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Username for 'https://github.com': redquinoa\n",
"\n",
"Password for 'https://redquinoa@github.com': \n",
"\n",
"Already up to date.\n",
"\n",
"```bash\n",
"git pull\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Already up to date."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Study guide: Basic Interaction with GitHub\n",
"\n",
"---\n",
"title: \"Study guide: Basic Interaction with GitHub | Coursera\"\n",
"source: \"https://www.coursera.org/learn/introduction-git-github/supplement/cOouv/study-guide-basic-interaction-with-github\"\n",
"author:\n",
" - \"[[Coursera]]\"\n",
"published:\n",
"created: 2025-03-07\n",
"description: \"In this module, youll be introduced to GitHub and learn how it works with Git. Youll create new repositories and clone those repositories onto your computer. Next, well explain what a remote repository is, how we can work with them, and how we ...\"\n",
"tags:\n",
" - \"clippings\"\n",
"---\n",
"There are various remote repository hosting sites:\n",
"\n",
"- [GitHub<svg aria-labelledby=\"cds-react-aria3604314262-:r3lv:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r3lv:\"><title id=\"cds-react-aria3604314262-:r3lv:-title\">Opens in a new tab</title></svg>](http://github.com/)\n",
"- [BitBucket<svg aria-labelledby=\"cds-react-aria3604314262-:r3m1:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r3m1:\"><title id=\"cds-react-aria3604314262-:r3m1:-title\">Opens in a new tab</title></svg>](https://bitbucket.org/product)\n",
"- [Gitlab<svg aria-labelledby=\"cds-react-aria3604314262-:r3m3:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r3m3:\"><title id=\"cds-react-aria3604314262-:r3m3:-title\">Opens in a new tab</title></svg>](https://gitlab.com/).\n",
"\n",
"Follow the workflow at [https://github.com/join<svg aria-labelledby=\"cds-react-aria3604314262-:r3m5:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r3m5:\"><title id=\"cds-react-aria3604314262-:r3m5:-title\">Opens in a new tab</title></svg>](https://github.com/join) to set up a free account, username, and password. After that, [these steps<svg aria-labelledby=\"cds-react-aria3604314262-:r3m7:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r3m7:\"><title id=\"cds-react-aria3604314262-:r3m7:-title\">Opens in a new tab</title></svg>](https://help.github.com/articles/create-a-repo/) will help you create a brand new repository on GitHub.\n",
"\n",
"Some useful commands for getting started:\n",
"\n",
"| Command | Explanation & Link |\n",
"| --- | --- |\n",
"| git clone URL | [Git clone is used to clone a remote repository into a local workspace<svg aria-labelledby=\"cds-react-aria3604314262-:r3m9:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r3m9:\"><title id=\"cds-react-aria3604314262-:r3m9:-title\">Opens in a new tab</title></svg>](https://git-scm.com/docs/git-clone) |\n",
"| git push | [Git push is used to push commits from your local repo to a remote repo<svg aria-labelledby=\"cds-react-aria3604314262-:r3mb:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r3mb:\"><title id=\"cds-react-aria3604314262-:r3mb:-title\">Opens in a new tab</title></svg>](https://git-scm.com/docs/git-push) |\n",
"| git pull | [Git pull is used to fetch the newest updates from a remote repository<svg aria-labelledby=\"cds-react-aria3604314262-:r3md:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r3md:\"><title id=\"cds-react-aria3604314262-:r3md:-title\">Opens in a new tab</title></svg>](https://git-scm.com/docs/git-pull) |\n",
"\n",
"This can be useful for keeping your local workspace up to date.\n",
"\n",
"- [https://help.github.com/en/articles/caching-your-github-password-in-git<svg aria-labelledby=\"cds-react-aria3604314262-:r3mf:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r3mf:\"><title id=\"cds-react-aria3604314262-:r3mf:-title\">Opens in a new tab</title></svg>](https://help.github.com/en/articles/caching-your-github-password-in-git)\n",
"- [https://help.github.com/en/articles/generating-an-ssh-key<svg aria-labelledby=\"cds-react-aria3604314262-:r3mh:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r3mh:\"><title id=\"cds-react-aria3604314262-:r3mh:-title\">Opens in a new tab</title></svg>](https://help.github.com/en/articles/generating-an-ssh-key)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Working with Remotes\n",
"\n",
"This reading contains the code used in the instructional videos from [**Working with remotes**<svg aria-labelledby=\"cds-react-aria3604314262-:r454:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r454:\"><title id=\"cds-react-aria3604314262-:r454:-title\">Opens in a new tab</title></svg>](https://www.coursera.org/learn/introduction-git-github/lecture/udUgl/working-with-remotes)\n",
"\n",
"## Introduction\n",
"\n",
"This follow-along reading is organized to match the content in the video that follows. It contains the same code shown in the next video. These code blocks will provide you with the opportunity to see how the code is written and can be used as a reference as you work through the course.\n",
"\n",
"You can follow along in the reading as the instructor discusses the code or review the code after watching the video.\n",
"\n",
"```bash\n",
"cd health\\-checks/\n",
"\n",
"git remote \\-v\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"origin  https://github.com/redquinoa/health-checks.git (fetch)\n",
"\n",
"origin  https://github.com/redquinoa/health-checks.git (push)\n",
"\n",
"```bash\n",
"git remote show origin\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Username for 'https://github.com': redquinoa\n",
"\n",
"Password for 'https://redquinoa@github.com': \n",
"\n",
"\\* remote origin\n",
"\n",
"  Fetch URL: https://github.com/redquinoa/health-checks.git\n",
"\n",
"  Push  URL: https://github.com/redquinoa/health-checks.git\n",
"\n",
"  HEAD branch: master\n",
"\n",
"  Remote branch:\n",
"\n",
"    master tracked\n",
"\n",
"  Local branch configured for 'git pull':\n",
"\n",
"    master merges with remote master\n",
"\n",
"  Local ref configured for 'git push':\n",
"\n",
"    master pushes to master (up to date)\n",
"\n",
"```bash\n",
"git branch \\-r\n",
"```\n",
"\n",
"**Code output:**\n",
"\n",
"  origin/HEAD -> origin/master\n",
"\n",
"  origin/master\n",
"\n",
"```bash\n",
"git status\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"On branch master\n",
"\n",
"Your branch is up to date with 'origin/master'.\n",
"\n",
"nothing to commit, working tree clean"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Fetching New Changes\n",
"\n",
"This reading contains the code used in the instructional videos from [**Fetching New Changes**<svg aria-labelledby=\"cds-react-aria3604314262-:r4dc:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r4dc:\"><title id=\"cds-react-aria3604314262-:r4dc:-title\">Opens in a new tab</title></svg>](https://www.coursera.org/learn/introduction-git-github/lecture/vbWpa/fetching-new-changes)\n",
"\n",
"## Introduction\n",
"\n",
"This follow-along reading is organized to match the content in the video that follows. It contains the same code shown in the next video. These code blocks will provide you with the opportunity to see how the code is written and can be used as a reference as you work through the course.\n",
"\n",
"You can follow along in the reading as the instructor discusses the code or review the code after watching the video.\n",
"\n",
"```bash\n",
"cd health\\-checks/\n",
"\n",
"git remote show origin\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"\\* remote origin\n",
"\n",
"  Fetch URL: https://github.com/redquinoa/health-checks.git\n",
"\n",
"  Push  URL: https://github.com/redquinoa/health-checks.git\n",
"\n",
"  HEAD branch: master\n",
"\n",
"  Remote branch:\n",
"\n",
"    master tracked\n",
"\n",
"  Local branch configured for 'git pull':\n",
"\n",
"    master merges with remote master\n",
"\n",
"  Local ref configured for 'git push':\n",
"\n",
"    master pushes to master (local out of date)\n",
"\n",
"```bash\n",
"git fetch\n",
"```\n",
"\n",
"**Code output:**\n",
"\n",
"remote: Enumerating objects: 5, done.\n",
"\n",
"remote: Counting objects: 100% (5/5), done.\n",
"\n",
"remote: Compressing objects: 100% (4/4), done.\n",
"\n",
"remote: Total 4 (delta 0), reused 4 (delta 0), pack-reused 0\n",
"\n",
"Unpacking objects: 100% (4/4), done.\n",
"\n",
"From https://github.com/redquinoa/health-checks\n",
"\n",
"   807cb50..b62dc2e  master     -> origin/master\n",
"\n",
"```bash\n",
"git log origin/master\n",
"```\n",
"\n",
"**Code output:**\n",
"\n",
"commit b62dc2eacfa820cd9a762adab9213305d1c8d344 (origin/master, origin/HEAD)\n",
"\n",
"Author: Blue Kale <bluekale@example.com>\n",
"\n",
"Date:   Mon Jan 6 14:32:45 2020 -0800\n",
"\n",
"    Add initial files for the checks\n",
"\n",
"commit 807cb5037ccac5512ba583e782c35f4e114f8599 (HEAD -> master)\n",
"\n",
"Author: My name <me@example.com>\n",
"\n",
"Date:   Mon Jan 6 14:09:41 2020 -800\n",
"\n",
"    Add one more line to README.md\n",
"\n",
"commit 3d9f86c50b8651d41adabdaebd04530f4694efb5\n",
"\n",
"Author: Red Quinoa <55592533+redquinoa@users.noreply.github.com>\n",
"\n",
"Date:   Sat Sep 21 14:04:15 2019 -0700\n",
"\n",
"    Initial commit\n",
"\n",
"```bash\n",
"git status\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"On branch master\n",
"\n",
"Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.\n",
"\n",
"  (use \"git pull\" to update your local branch)\n",
"\n",
"nothing to commit, working tree clean\n",
"\n",
"```bash\n",
"git merge origin/master\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Updating 807cb50..b62dc2e\n",
"\n",
"Fast-forward\n",
"\n",
" all\\_checks.py | 18 ++++++++++++++++++\n",
"\n",
" disk\\_usage.py | 24 ++++++++++++++++++++++++\n",
"\n",
" 2 files changed, 42 insertions(+)\n",
"\n",
" create mode 100755 all\\_checks.py\n",
"\n",
" create mode 100644 disk\\_usage.py\n",
"\n",
"```bash\n",
"git log\n",
"```\n",
"\n",
"**Code output:**\n",
"\n",
"commit 1e0a1dfccf01183bfca7e30fb25f115889f95022 (HEAD -> master, origin/master, origin/HEAD)\n",
"\n",
"commit b62dc2eacfa820cd9a762adab9213305d1c8d344 (HEAD -> master, origin/master, origin/HEAD)\n",
"\n",
"Author: Blue Kale <bluekale@example.com>\n",
"\n",
"Date:   Mon Jan 6 14:32:45 2020 -0800\n",
"\n",
"    Add initial files for the checks\n",
"\n",
"commit 807cb5037ccac5512ba583e782c35f4e114f8599 (HEAD -> master)\n",
"\n",
"Author: My name <me@example.com>\n",
"\n",
"Date:   Mon Jan 6 14:09:41 2020 -800\n",
"\n",
"    Add one more line to README.md\n",
"\n",
"commit 3d9f86c50b8651d41adabdaebd04530f4694efb5\n",
"\n",
"Author: Red Quinoa <55592533+redquinoa@users.noreply.github.com>\n",
"\n",
"Date:   Sat Sep 21 14:04:15 2019 -0700"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Updating the Local Repository\n",
"\n",
"This reading contains the code used in the instructional videos from [**Updating the Local Repository**<svg aria-labelledby=\"cds-react-aria3604314262-:r4m2:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r4m2:\"><title id=\"cds-react-aria3604314262-:r4m2:-title\">Opens in a new tab</title></svg>](https://www.coursera.org/learn/introduction-git-github/lecture/UjnyI/updating-the-local-repository)\n",
"\n",
"## Introduction\n",
"\n",
"This follow-along reading is organized to match the content in the video that follows. It contains the same code shown in the next video. These code blocks will provide you with the opportunity to see how the code is written and can be used as a reference as you work through the course.\n",
"\n",
"You can follow along in the reading as the instructor discusses the code or review the code after watching the video.\n",
"\n",
"```bash\n",
"git pull\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"remote: Enumerating objects: 8, done.\n",
"\n",
"remote: Counting objects: 100% (8/8), done.\n",
"\n",
"remote: Compressing objects: 100% (5/5), done.\n",
"\n",
"Unpacking objects: 100% (6/6), done.\n",
"\n",
"remote: Total 6 (delta 1), reused 6 (delta 1), pack-reused 0\n",
"\n",
"From https://github.com/redquinoa/health-checks\n",
"\n",
"   807cb50..b62dc2e  master       -> origin/master\n",
"\n",
" \\* \\[new branch\\]      experimental -> origin/experimental\n",
"\n",
"Updating 807cb50..b62dc2e\n",
"\n",
"Fast-forward\n",
"\n",
" all\\_checks.py | 15 +++++++++++++++\n",
"\n",
" 1 file changed, 15 insertions(+)\n",
"\n",
"```bash\n",
"git \\-log \\-p \\-1\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"commit 922d65950b5325109525a24b71d8df8a46412d04 (HEAD -> master, origin/master, origin/HEAD)\n",
"\n",
"Author: Blue Kale <bluekale@example.com>\n",
"\n",
"Date:   Mon Jan 6 14:42:44 2020 -0800\n",
"\n",
"    Add disk full check to all\\_checks.py\n",
"\n",
"diff --git a/all\\_checks.py b/all\\_checks.py\n",
"\n",
"index fdc4476..e46cdae 100755\n",
"\n",
"\\--- a/all\\_checks.py\n",
"\n",
"+++ b/all\\_checks.py\n",
"\n",
"@@ -1,16 +1,31 @@\n",
"\n",
" #!/usr/bin/env python3\n",
"\n",
" import os\n",
"\n",
"+import shutil\n",
"\n",
" import sys\n",
"\n",
"(...)\n",
"\n",
"def(check\\_reboot): \n",
"\n",
"\"\"\" Returns True if the computer has a pending reboot.\"\"\"\n",
"\n",
"Return os.path.exists(“/run/reboot-required”)\n",
"\n",
"+def check\\_disk\\_full(disk, mmin\\_absolute, min\\_percent):\n",
"\n",
"\\+ \"\"\"Returns True if there isnt enough disk space, False otherwise.\"\"\"\n",
"\n",
"\\+ du = shutil.disk\\_usage(disk)\n",
"\n",
"\\+ # Calculate the percentage of free space\n",
"\n",
"\\+ percent\\_free = 100 \\* du.free / du.total\n",
"\n",
"\\+ # Calculate how many free gigabytes\n",
"\n",
"```bash\n",
"git remote show origin\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"\\* remote origin\n",
"\n",
"  Fetch URL: https://github.com/redquinoa/health-checks.git\n",
"\n",
"  Push  URL: https://github.com/redquinoa/health-checks.git\n",
"\n",
"  HEAD branch: master\n",
"\n",
"  Remote branches:\n",
"\n",
"    experimental tracked\n",
"\n",
"    master       tracked\n",
"\n",
"  Local branch configured for 'git pull':\n",
"\n",
"    master merges with remote master\n",
"\n",
"  Local ref configured for 'git push':\n",
"\n",
"    master pushes to master (up to date)\n",
"\n",
"```bash\n",
"git checkout experimental \n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Branch 'experimental' set up to track remote branch 'experimental' from 'origin'.\n",
"\n",
"Switched to a new branch 'experimental'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Study guide: Git Remotes\n",
"\n",
"Youve learned about what a remote is, working with remotes, fetching new changes, and updating the local repository. Use this study guide as an easy reference of Git commands for working with remotes. This study guide gives a brief explanation of these useful commands along with a link to the Git documentation for each command. Keeping study guides like this one easily accessible can help you code more efficiently.\n",
"\n",
"| Command | Explanation & Links |\n",
"| --- | --- |\n",
"| git remote | [$ git remote<svg aria-labelledby=\"cds-react-aria3604314262-:r54k:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r54k:\"><title id=\"cds-react-aria3604314262-:r54k:-title\">Opens in a new tab</title></svg>](https://git-scm.com/docs/git-remote) allows you to manage the set of repositories or “remotes” whose branches you track. |\n",
"| git remote -v | [$ git remote -v<svg aria-labelledby=\"cds-react-aria3604314262-:r54m:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r54m:\"><title id=\"cds-react-aria3604314262-:r54m:-title\">Opens in a new tab</title></svg>](https://git-scm.com/docs/git-remote#Documentation/git-remote.txt--v) is similar to $ git remote, but adding the -v shows more information such as the remote URL. |\n",
"| git remote show <name> | [$ git remote show <name><svg aria-labelledby=\"cds-react-aria3604314262-:r54o:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r54o:\"><title id=\"cds-react-aria3604314262-:r54o:-title\">Opens in a new tab</title></svg>](https://git-scm.com/docs/git-remote#Documentation/git-remote.txt-emshowem) shows some information about a single remote repo. |\n",
"| git remote update | [$ git remote update<svg aria-labelledby=\"cds-react-aria3604314262-:r54q:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r54q:\"><title id=\"cds-react-aria3604314262-:r54q:-title\">Opens in a new tab</title></svg>](https://git-scm.com/docs/git-remote#Documentation/git-remote.txt-emupdateem) fetches updates for remotes or remote groups. |\n",
"| git fetch | [$ git fetch<svg aria-labelledby=\"cds-react-aria3604314262-:r54s:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r54s:\"><title id=\"cds-react-aria3604314262-:r54s:-title\">Opens in a new tab</title></svg>](https://git-scm.com/docs/git-fetch) can download objects and refs from a single repo, a single URL, or from several repositories at once. |\n",
"| git branch -r | [$ git branch -r<svg aria-labelledby=\"cds-react-aria3604314262-:r54u:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r54u:\"><title id=\"cds-react-aria3604314262-:r54u:-title\">Opens in a new tab</title></svg>](https://git-scm.com/docs/git-branch#Documentation/git-branch.txt--r) lists remote branches and can be combined with other branch arguments to manage remote branches. |\n",
"\n",
"Keep this table handy while you are getting comfortable using Git remotes. Now, its time to put your newfound knowledge of Git remotes to use!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# What is secure shell?\n",
"\n",
"Secure Shell (SSH) is a robust protocol for connecting to servers remotely. In the realm of remote server access, security is going to be more and more important to keep your information safe. Secure Shell is primarily used for logging in to Linux servers, Unix servers, and certain networking equipment such as routers. \n",
"\n",
"## Alternatives to SSH\n",
"\n",
"SSH provides a shield against prying eyes, but how does it compare to its alternatives?  \n",
"\n",
"Telnet is one popular alternative. Telnet exposes your typed commands, including passwords, to anyone on the network equipped with the right tools. \n",
"\n",
"Although Transport Layer Security (TLS) encrypts data within web browsers, SSH secures data in interactive terminal sessions or file transfers. This encryption ensures that sensitive information remains confidential during communication. \n",
"\n",
"Another alternative is virtual private networks (VPNs). VPNs also offer encryption but grant access to entire networks after connection. SSH adheres to the principle of least privilege, restricting users to specific hosts, enhancing security. \n",
"\n",
"Another option might be remote-control software like VNC or GoToMyPC. They focus on graphical user interfaces and desktop experiences, which may not align with most Linux servers that operate sans desktop environments.\n",
"\n",
"## Operation\n",
"\n",
"SSH operates through two key components: the SSH server and the SSH client. The SSH server, residing on the target server, establishes secure network connections, undergoes mutual authentication, and initiates encrypted login sessions or file transfers. \n",
"\n",
"Conversely, the SSH client establishes a connection to the SSH server, ensuring a secure interaction. The client makes requests, such as “log me in” or “copy this file.”\n",
"\n",
"## SSH keys\n",
"\n",
"In the SSH protocol, an access credential is known as an SSH key. It serves a similar purpose as usernames and passwords, although system administrators and power users typically use the keys to automate procedures and achieve single sign-on.\n",
"\n",
"Displaying the fingerprint of an SSH key is a useful way to verify that you're using the correct key and that the remote server's key hasn't been tampered with. To display the fingerprint of an SSH key, you can use the ssh-keygen command-line tool. \n",
"\n",
"## Key takeaways\n",
"\n",
"**SSH prioritizes security in remote server access:** Secure Shell (SSH) is a robust and trusted protocol for securely connecting to servers remotely. It finds widespread use in accessing Linux servers, Unix servers, and specific networking equipment, serving as a shield against unauthorized access and data breaches. \n",
"\n",
"**Comparing SSH with alternatives:** When you compare SSH to alternatives like Telnet, its security superiority becomes clear. Telnet exposes commands, including passwords, to potential threats, whereas SSH's encryption guarantees confidentiality during interactive terminal sessions and file transfers. Unlike virtual private networks (VPNs) that offer network-wide access, SSH adheres to the principle of least privilege, ensuring users are restricted for enhanced security.\n",
"\n",
"**SSH's operational mechanics and key role:** SSH functions through two core components: the SSH server and the SSH client. The SSH server establishes secure connections, authenticates parties involved, and initiates encrypted sessions. Conversely, the SSH client establishes secure interactions with the server and enables actions like secure login or file copying.\n",
"\n",
"Just like a password, the security of your SSH key is critical. Never share your SSH private key with anyone or put SSH keys into your application code. With someone having access to your information, they can gain unauthorized access by logging in and pretending to be you."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# The SSH protocol\n",
"\n",
"When discussing computer networks, the word “shell” refers to a program that provides an interface for accessing another operating system. With all the effort you put into keeping your own machine secure, you certainly want security when its connected to another machine. The Secure Shell network protocol, usually shorthanded to “SSH,” allows secure access to a computer over an unsecured network. \n",
"\n",
"## What is a protocol? \n",
"\n",
"A protocol is a set of rules for how two things should communicate with each other. You may have heard the phrase “military protocol,” which refers to the strict guidelines that govern communications between members of the armed forces in all situations. \n",
"\n",
"In the case of computer protocols, these are usually published as open standards so that any given protocol can be implemented in various products. Having these protocols readily available to everyone means that any machine or network that implements a given protocol should be able to communicate seamlessly with anything else that supports the same protocol. \n",
"\n",
"For a deeper dive into Secure Shell, see [SSH protocol<svg aria-labelledby=\"cds-react-aria3604314262-:r5ed:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r5ed:\"><title id=\"cds-react-aria3604314262-:r5ed:-title\">Opens in a new tab</title></svg>](https://www.ssh.com/academy/ssh/protocol). \n",
"\n",
"## The SSH protocol\n",
"\n",
"So how does SSH secure the network? It works on the principle of public-key encryption. The client and the server each generate a strong encryption key for any data that is passed between them. Then, that key gets split in half, with the client retaining one portion and the server keeping the other. Its a complex version of a simple idea, really; its not hard to imagine two people making up an encryption code and then tearing it in half for extra secrecy. \n",
"\n",
"In SSH, the keys are split between a public key, the public half of the servers encryption key, and the private key, which is stored only on the server. This way, a users machine can encrypt a message using the public key, but only the connected server can decode it because only the servers private key will successfully decrypt the message. This way, if someone did intercept the network traffic, they still couldnt read it because they dont have the servers private key. Using SSH, your keystrokes and the servers responses are completely secure. \n",
"\n",
"For more on these keys, see [Public private key pairs & how they work<svg aria-labelledby=\"cds-react-aria3604314262-:r5ef:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r5ef:\"><title id=\"cds-react-aria3604314262-:r5ef:-title\">Opens in a new tab</title></svg>](https://www.preveil.com/blog/public-and-private-key/#:~:text=In%20public%20key%20cryptography%2C%20every,using%20their%20matching%20private%20key.) and [A Deep Dive on End-to-End Encryption<svg aria-labelledby=\"cds-react-aria3604314262-:r5eh:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r5eh:\"><title id=\"cds-react-aria3604314262-:r5eh:-title\">Opens in a new tab</title></svg>](https://ssd.eff.org/module/deep-dive-end-end-encryption-how-do-public-key-encryption-systems-work). \n",
"\n",
"## Using the SSH protocol\n",
"\n",
"The SSH protocol is commonly used for logging in to servers remotely. While it is primarily used for logging in to Linux and Unix servers, it is also used to encrypt file transfers and to log in to some network equipment, like routers. \n",
"\n",
"Of course, your private key should never be transmitted to anyone else or shared anywhere. Most SSH clients will not connect if your private key is not protected from other users. Because your private key is unique to you, it can serve as both authentication and encryption, so the server doesnt need to ask you for a password.\n",
"\n",
"Besides providing a secure login shell on a remote server, SSH can be used for a number of other functions, including:\n",
"\n",
"- Transferring files between client and server with SCP (Secure Copy Protocol) or SFTP (Secure File Transfer Protocol); for more about these types of file transfers, see the [Difference between SFTP and SCP<svg aria-labelledby=\"cds-react-aria3604314262-:r5ej:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r5ej:\"><title id=\"cds-react-aria3604314262-:r5ej:-title\">Opens in a new tab</title></svg>](https://www.tutorialspoint.com/difference-between-sftp-and-scp).\n",
"- Forwarding network ports from server to client, or “tunneling”; for more on port forwarding, see [How to Use SSH Port Forwarding<svg aria-labelledby=\"cds-react-aria3604314262-:r5el:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r5el:\"><title id=\"cds-react-aria3604314262-:r5el:-title\">Opens in a new tab</title></svg>](https://phoenixnap.com/kb/ssh-port-forwarding).\n",
"- Relaying your login to yet another server behind a firewall, sometimes referred to as a “jump box” or “bastion host”; for more on this relaying method, see [How to Set Up an SSH Jump Server<svg aria-labelledby=\"cds-react-aria3604314262-:r5en:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r5en:\"><title id=\"cds-react-aria3604314262-:r5en:-title\">Opens in a new tab</title></svg>](https://goteleport.com/blog/ssh-jump-server/).\n",
"- Running graphical user interface (GUI) applications on a server but displaying them on a local client; for more on this, see [Use X forwarding on a personal computer<svg aria-labelledby=\"cds-react-aria3604314262-:r5ep:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r5ep:\"><title id=\"cds-react-aria3604314262-:r5ep:-title\">Opens in a new tab</title></svg>](https://kb.iu.edu/d/bdnt)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Configuring SSH\n",
"\n",
"Computer ports are software-based points where a network connection begins and ends. When using Secure Shell (SSH), the client connects to the server on port 22. After the connection is made, the server sends its public key to the client. Then the client and server negotiate a set of encryption rules, called an encryption algorithm, that both machines can support. When the two machines are in agreement on the encryption algorithm, the server starts a login shell for the user. \n",
"\n",
"![A diagram shows an SSH client connecting to an SSH server. Information is exchanged until a secure connection is es](https://d3c33hcgiwev3.cloudfront.net/imageAssetProxy.v1/pI1RKqVSSp21_OdEfwUMww_6cffd8ebb7084820bbc53b564ef0e1f1_BudE_s6geqadKlUkfb06AWNR4PFzNYzeb0-aOgYqQkSz2R2jbLYmKBT4ILRoxJ3_8Ew7lqJKd4JyZpRqTzhReNUSzUc40EUq34n_Fk819HY20sAjsyGolwZT4iGvyewpB8iZxGt075kRnnT9LO0ZaKw?expiry=1741478400000&hmac=DWn_L1p39kdloNNjfkV533w6T_cEwErpBG3giRoHnFI)\n",
"\n",
"## Configuring an SSH client\n",
"\n",
"SSH configuration instructions will be different depending on your operating system and the implementation of SSH. On the other hand, instructions for a client to generate its SSH key and connect to a server are more general. Lets look at how to set up the command-line OpenSSH client and connect to a remote host for the first time. \n",
"\n",
"### Generating your key pair\n",
"\n",
"First, you will need to generate your public/private key pair. The first time you connect to a given server using SSH, the server will store a copy of its public key on your machine. This needs to be done only once, as the same key pair can be used to connect to any number of remote hosts.\n",
"\n",
"Open a terminal and enter the command: \n",
"\n",
"ssh-keygen -t rsa -b 2048\n",
"\n",
"OpenSSH will ask where to save the generated keys. Note that it will create a hidden directory called .ssh in your home directory. You can accept the defaults here. \n",
"\n",
"SSH will also ask you for a passphrase to protect your key. Many people choose not to use a passphrase because if you enter a passphrase here, you will be required to enter it every time your key is used. If you are on a machine that is not secure, however, someone who gains access to that computer will also have access to every system that uses that key. \n",
"\n",
"If you add a passphrase to your SSH key for added security, you can save the passphrase to an SSH agent, which is a program that manages SSH keys. For more about working with SSH key passphrases, see [Adding your SSH key to the ssh-agent<svg aria-labelledby=\"cds-react-aria3604314262-:r5h9:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r5h9:\"><title id=\"cds-react-aria3604314262-:r5h9:-title\">Opens in a new tab</title></svg>](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent). \n",
"\n",
"After you have set your passphrase or declined the option, OpenSSH will then generate a random public/private key pair and save it. Depending on your hardware, this may take several seconds to complete. OpenSSH will then return a message that your key has been saved and display the fingerprint and a “randomart image” of your new key. Here is an example:\n",
"\n",
"```bash\n",
"Generating public/private rsa key pair.\n",
"\n",
"Enter file in which to save the key (/Users/tradel/.ssh/id\\_rsa): \n",
"\n",
"Created directory '/Users/tradel/.ssh'.\n",
"\n",
"Enter passphrase (empty for no passphrase): \n",
"\n",
"Enter same passphrase again: \n",
"\n",
"Your identification has been saved in /Users/tradel/.ssh/id\\_rsa\n",
"\n",
"Your public key has been saved in /Users/tradel/.ssh/id\\_rsa.pub\n",
"\n",
"The key fingerprint is:\n",
"\n",
"SHA256:0P4GpCFXlVoZPoQ8ULdqq9L0p2KTYlMwtOLXIwSxfO8 tradel@Todds-MacBook-Pro.local\n",
"\n",
"The key's randomart image is:\n",
"\n",
"+---\\[RSA 2048\\]----+\n",
"\n",
"|  ..  .+oo=+     |\n",
"\n",
"| ....  o+++.     |\n",
"\n",
"|  ooo.+ o++      |\n",
"\n",
"|  ..=+ \\*.. .     |\n",
"\n",
"| . o +o S        |\n",
"\n",
"|  . o.=. +       |\n",
"\n",
"|   . =E+. o      |\n",
"\n",
"|    = \\*....      |\n",
"\n",
"|   . =.o.o       |\n",
"\n",
"+----\\[SHA256\\]-----+\n",
"```\n",
"\n",
"## Connecting for the first time\n",
"\n",
"Now that you have a key pair, you can connect to a host. The most basic form of the command to connect is: \n",
"\n",
"ssh <username>@<hostname>.\n",
"\n",
"When you connect to a server for the first time, SSH will print out the fingerprint of the remote servers key and confirm that you really want to connect. The request will look like this:\n",
"\n",
"```bash\n",
"The authenticity of host 'my-host (192.168.1.10)' can't be established.\n",
"\n",
"ED25519 key fingerprint is SHA256:KyE8fOzengv6CRTe1EXaeO7dtIF9JKM0VAcKf6sA0RM.\n",
"\n",
"This key is not known by any other names\n",
"\n",
"Are you sure you want to continue connecting (yes/no/\\[fingerprint\\])? yes\n",
"\n",
"Warning: Permanently added 'my-host' (ED25519) to the list of known hosts.\n",
"```\n",
"\n",
"You may be asked to enter the password for the account on the remote host. After you do this, a copy of your public key will be stored on the host, and you will not have to enter your password again. Your own copy of your key is sufficient to authenticate your connection. \n",
"\n",
"## Configuring an SSH server\n",
"\n",
"As we said earlier, SSH server configuration will vary based on your operating system and implementation of SSH. The SSH server component, called a “daemon,” is often installed by default on Linux and Unix. On Linux, the server configuration file is usually at /etc/ssh/sshd\\_config and rarely needs to be changed. \n",
"\n",
"If you try to connect to a host and see an error like “ssh: connection refused”, consult your operating system documentation for how to install and enable the SSH daemon. \n",
"\n",
"For use cases like increased security or managing user connections, see [How To Tune your SSH Daemon Configuration on a Linux VPS<svg aria-labelledby=\"cds-react-aria3604314262-:r5hl:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r5hl:\"><title id=\"cds-react-aria3604314262-:r5hl:-title\">Opens in a new tab</title></svg>](https://www.digitalocean.com/community/tutorials/how-to-tune-your-ssh-daemon-configuration-on-a-linux-vps).\n",
"\n",
"Later versions of MacOS also have a command-line SSH client already installed. For a free implementation of SSH for Windows, Mac, and Unix, see [PuTTY: a free SSH and Telnet client<svg aria-labelledby=\"cds-react-aria3604314262-:r5hn:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r5hn:\"><title id=\"cds-react-aria3604314262-:r5hn:-title\">Opens in a new tab</title></svg>](https://www.chiark.greenend.org.uk/~sgtatham/putty/). \n",
"\n",
"## Pro Tips \n",
"\n",
"You can use the same private/public key pair across all the machines you control. So if you have two laptops and a tablet, you could copy your key pair to all of them. This can save you a few steps when logging in from other devices.\n",
"\n",
"Once SSH is set up, if the public key sent by the server ever changes, SSH will warn you that something malicious may have happened to the server. You will receive an alert message that states the “Remote host identification has changed” or similar. You should contact your systems administrator if you see this message. Although its possible that the server has simply updated its key, its also possible that someone is eavesdropping on communications between you and an application in order to steal information. \n",
"\n",
"Optional features like port forwarding are often disabled by default because they open up potential security holes if they are misused. You may need these optional features to be enabled for something like forwarding network ports from a remote host to your local machine; for instance, if you want to access a service on the host (or the host's network) that is blocked by a firewall. If you need these optional features enabled, turn them on in the sshd\\_config file."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# API Keys\n",
"\n",
"An Application Programming Interface (API) key is an authentication token that allows you to call an API. An application passes an API key to the API, which is then called to identify the person, programmer, or program trying to access a website. It is frequently accompanied by a set of access rights that are specific to the API the key is linked to. In this reading, you will delve into API keys, their role, their function in authentication and authorization, and how they are used. \n",
"\n",
"The API key is usually randomly generated by the application and must be sent on every API call. It serves as a distinctive identifier and offers a secure token for authentication.\n",
"\n",
"## Authentication and authorization\n",
"\n",
"API keys may be used for both authentication, making sure youre who you say you are, and authorization, deciding which APIs you are allowed to call.\n",
"\n",
"When you are authenticating with API keys, you are ensuring that malicious users or applications cant call an API and make unauthorized or authorized changes. With project authentication (application or site authentication), API keys help identify the project or application that makes the call. If you are using API keys for user authentication, the identity of the user is being verified. \n",
"\n",
"When you are authorizing with API keys, you are also ensuring that you have the correct API call. Authorization will also check that the API key being used in the project is available.\n",
"\n",
"## How they are used\n",
"\n",
"When using APIs, the usage depends on the specific API. With most APIs, you are required to send the API key with every request. It can be sent in one of several ways:\n",
"\n",
"1. As an HTTP parameter in the request URL. Example: GET https://myapp.com/api/users/list?apikey=12345678\n",
"2. As an HTTP header sent with the request. Example: GET https://myapp.com/api/users/listX-API-Key: 12345678\n",
"3. (Rarely) Posted to a specific authorization endpoint, which returns another token or a cookie to be sent with subsequent requests. Example: POST https://myapp.com/api/auth{ “token”: “12345678” }\n",
"\n",
"One last tip, do not hardcode API keys into your application code, especially if it will be posted in a public repository like Github. If you have hardcoded your API keys into your application code, anyone who wants to can make API calls with your authorization! \n",
"\n",
"Unfortunately, it happens every day. For this reason, many applications are moving away from API keys and toward OAuth, which requires the user to manually authorize an application before using it. With being extra cautious, you can make sure this does not happen to you. \n",
"\n",
"## Key takeaways\n",
"\n",
"- **API keys facilitate secure interactions:** The API key serves as a crucial authentication token that not only permits API calls, but also plays a vital role in regulating access privileges and defining permissible actions. It's an essential tool in ensuring secure and controlled communication within digital ecosystems.\n",
"- **Authentication and authorization:** API keys serve a dual purpose: authentication and authorization. Authentication verifies the identity of users or applications making API calls, preventing unauthorized access or changes. Authorization, on the other hand, ensures that users have the appropriate rights to call specific APIs, promoting controlled usage and adherence to access policies.\n",
"- **Effective API key usage:** When using APIs, the API key can be included as an HTTP parameter in the URL or an HTTP header. Ensuring that API keys aren't hardcoded in application code is important in order to prevent unauthorized access. Many applications are transitioning from API keys to more secure methods where manual user authorization enhances security measures and minimizes risks associated with API misuse."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# When to use API Keys\n",
"\n",
"Managing access and safeguarding resources is where API keys come into play. An API may require API keys for part or all of its methods. In this reading, we delve into the concept of API keys, exploring their pivotal role in not only securing and controlling access, but also in gathering insights to some processes API keys should not be used for. \n",
"\n",
"There are a few reasons why you might want to use API keys.\n",
"\n",
"## What you can use API keys for\n",
"\n",
"Some of the ways you might use API keys include: \n",
"\n",
"- **To block anonymous traffic** - Can help to protect your API from abuse and to ensure that only authorized users are able to access it.\n",
"- **To control the number of calls made to your API** - Can help to prevent your API from being overloaded and to ensure that it is available to all authorized users.\n",
"- **To identify usage patterns** - Can be used to improve your API and to make sure that it is meeting the needs of your users.\n",
"- **To filter logs by API key** - Can help you to troubleshoot problems with your API and to identify which users are using your API the most.\n",
"\n",
"## What you cannot use API keys for\n",
"\n",
"You cant use API keys for: \n",
"\n",
"- **Identifying individual users** - API keys do not identify individual users; they identify entire projects.\n",
"- **Secure authorization** - They should be used only to identify and control access to an API.\n",
"- **Identifying the creators of a project** - Service Infrastructure doesn't provide a method to directly look up projects from API keys.\n",
"\n",
"## Key Takeaways\n",
"\n",
"- You use API keys for blocking anonymous traffic, controlling the number of calls made to your API, identifying usage patterns, and to filter logs by API keys.\n",
"- You cant use API keys for identifying individual users, securing authorization, and identifying the creators of a project.\n",
"\n",
"API keys serve as the link between the potential of APIs and the demand for restricted usage. As developers continue to harness the power of APIs to weave intricate software ecosystems, a nuanced understanding of API keys' capabilities and boundaries becomes the cornerstone of ensuring secure, efficient, and insightful API management."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Public vs. private keys\n",
"\n",
"In a rapidly evolving world of technology, it is more critical than ever to establish security policies throughout an organization that safeguard valuable information and data assets. Asymmetric cryptography relies on public and private keys as its core building blocks to maintain data security and confidentiality in the face of dangers. However, to enable organizations to make wise decisions that will protect online interactions and information, it is important that we understand when public and private keys are used and how to do so effectively.\n",
"\n",
"## What is a public key?\n",
"\n",
"A public key is frequently employed to establish secure communication through data encryption or to validate the authenticity of a digital signature. Safety is ensured because the public key comes from a trusted certificate authority, which gives digital certificates verifying the owners identity and key. Public keys are created through an asymmetric algorithm that conducts several operations on a pair of connected keys before being transmitted over the internet.\n",
"\n",
"## What is a private key?\n",
"\n",
"A private key is a secret and secure key that must be kept confidential and protected. Its role involves decryption and the creation of digital signatures, assuring the data's integrity and authenticity. It is the counterpart of the public key and is shared to decrypt encoded information. Any data encrypted using the private key can be decrypted using the corresponding public key.\n",
"\n",
"## How do public and private keys work together?\n",
"\n",
"Public and private keys work together to ensure secure communication, data encryption, digital signatures, and key exchanges take place safely across various communication channels. This process encompasses:\n",
"\n",
"1. Key generation: A public and private key is generated for both the sender and receiver.\n",
"2. Key exchange: The public keys are exchanged between sender and receiver.\n",
"3. Encryption: The sender encrypts their data using the recipient's public key.\n",
"4. Transmitting encrypted data: The encrypted data is transmitted to the recipient.\n",
"5. Decryption: The recipient decrypts the message using their exclusive private key.\n",
"\n",
"## Key takeaway\n",
"\n",
"In summary, although public and private keys are distinct, they work together to create a powerful and flexible foundation for achieving data security, confidentiality, integrity, and authentication in a wide range of digital settings."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# The Pull-Merge-Push Workflow\n",
"\n",
"This reading contains the code used in the instructional videos from [**The Pull-Merge-Push Workflow**<svg aria-labelledby=\"cds-react-aria3604314262-:r5s5:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r5s5:\"><title id=\"cds-react-aria3604314262-:r5s5:-title\">Opens in a new tab</title></svg>](https://www.coursera.org/learn/introduction-git-github/lecture/n3GnN/the-pull-merge-push-workflow)\n",
"\n",
"## Introduction\n",
"\n",
"This follow-along reading is organized to match the content in the video that follows. It contains the same code shown in the next video. These code blocks will provide you with the opportunity to see how the code is written and can be used as a reference as you work through the course.\n",
"\n",
"You can follow along in the reading as the instructor discusses the code or review the code after watching the video.\n",
"\n",
"```bash\n",
"atom all\\_checks.py\n",
"\n",
"#!/usr/binenv python3\n",
"\n",
"(...)\n",
"\n",
"def check\\_disk\\_full(disk, min\\_gb, min\\_percent):\n",
"\n",
"    \"\"\"Returns True if there isn't enough disk space, False otherwise.\"\"\"\n",
"\n",
"    du = shutil.disk\\_usage(disk)\n",
"\n",
"    # Calculate the percentage of free space\n",
"\n",
"    percent\\_free = 100 \\* du.free / du.total\n",
"\n",
"    # Calculate how many free gigabytes\n",
"\n",
"    gigabytes\\_free = du.free / 2\\*\\*30\n",
"\n",
"    if percent\\_free < min\\_percent or gigabytes\\_free < min\\_gb:\n",
"\n",
"        return True\n",
"\n",
"    return False\n",
"\n",
"def main(): \n",
"\n",
"    if check\\_reboot():\n",
"\n",
"        print(\"Pending Reboot.\")\n",
"\n",
"        sys\\_exit(1)\n",
"\n",
"    if check\\_disk\\_full(disk=\"/\", min\\_gb=2, min\\_percent=10):\n",
"\n",
"        print(\"Disk full.\")\n",
"\n",
"        sys.exit(1)\n",
"\n",
"    print(\"Everything ok\")\n",
"\n",
"    sys.exit(0)\n",
"\n",
"main()\n",
"```\n",
"\n",
"```bash\n",
"git add \\-p\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"diff --git a/all\\_checks.py b/all\\_checks.py\n",
"\n",
"index e46cdae..a40047c 100755\n",
"\n",
"\\--- a/all\\_checks.py\n",
"\n",
"+++ b/all\\_checks.py\n",
"\n",
"@@ -8,14 +8,14 @@ def check\\_reboot():\n",
"\n",
"     \"\"\"Returns True if the computer has a pending reboot.\"\"\"\n",
"\n",
"     return os.path.exists(\"/run/reboot-required\")\n",
"\n",
"\\-def check\\_disk\\_full(disk, min\\_absolute, min\\_percent):\n",
"\n",
"+def check\\_disk\\_full(disk, min\\_gb, min\\_percent):\n",
"\n",
"     \"\"\"Returns True if there isn't enough disk space, False otherwise.\"\"\"\n",
"\n",
"     du = shutil.disk\\_usage(disk)\n",
"\n",
"     # Calculate the percentage of free space\n",
"\n",
"     percent\\_free = 100 \\* du.free / du.total\n",
"\n",
"     # Calculate how many free gigabytes\n",
"\n",
"     gigabytes\\_free = du.free / 2\\*\\*30\n",
"\n",
"\\-    if percent\\_free < min\\_percent or gigabytes\\_free < min\\_absolute:\n",
"\n",
"+    if percent\\_free < min\\_percent or gigabytes\\_free < min\\_gb:\n",
"\n",
"         return True\n",
"\n",
"     return False\n",
"\n",
"Stage this hunk \\[y,n,q,a,d,j,J,g,/,s,e,?\\]? y\n",
"\n",
"@@ -27,7 +27,7 @@ def main():\n",
"\n",
"     if check\\_reboot():\n",
"\n",
"         print(\"Pending Reboot.\")\n",
"\n",
"         sys.exit(1)\n",
"\n",
"\\-    if check\\_disk\\_full(\"/\", 2, 10):\n",
"\n",
"+    if check\\_disk\\_full(disk=\"/\", min\\_gb=2, min\\_percent=10):\n",
"\n",
"         print(\"Disk full.\")\n",
"\n",
"         sys.exit(1)\n",
"\n",
"Stage this hunk \\[y,n,q,a,d,K,g,/,e,?\\]? y\n",
"\n",
"```bash\n",
"git commit \\-m 'Rename min\\_absolute to min\\_gb, use parameter names'\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"\\[master 03923d0\\] Rename min\\_absolute to min\\_gb, use parameter names\n",
"\n",
" 1 file changed, 3 insertions(+), 3 deletions(-)\n",
"\n",
"```bash\n",
"git push\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Username for 'https://github.com': redquinoa\n",
"\n",
"Password for 'https://redquinoa@github.com': \n",
"\n",
"To https://github.com/redquinoa/health-checks.git\n",
"\n",
" ! \\[rejected\\]        master -> master (fetch first)\n",
"\n",
"error: failed to push some refs to 'https://github.com/redquinoa/health-checks.git'\n",
"\n",
"hint: Updates were rejected because the remote contains work that you do\n",
"\n",
"hint: not have locally. This is usually caused by another repository pushing\n",
"\n",
"hint: to the same ref. You may want to first integrate the remote changes\n",
"\n",
"hint: (e.g., 'git pull ...') before pushing again.\n",
"\n",
"hint: See the 'Note about fast-forwards' in 'git push --help' for details.\n",
"\n",
"```bash\n",
"git pull\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"remote: Enumerating objects: 5, done.\n",
"\n",
"remote: Counting objects: 100% (5/5), done.\n",
"\n",
"remote: Compressing objects: 100% (2/2), done.\n",
"\n",
"remote: Total 3 (delta 1), reused 3 (delta 1), pack-reused 0\n",
"\n",
"Unpacking objects: 100% (3/3), done.\n",
"\n",
"From https://github.com/red-quinoa/health-checks\n",
"\n",
"   92d659..a2dc118  master     -> origin/master\n",
"\n",
"Auto-merging all\\_checks.py\n",
"\n",
"CONFLICT (content): Merge conflict in all\\_checks.py\n",
"\n",
"Automatic merge failed; fix conflicts and then commit the result.\n",
"\n",
"```bash\n",
"git log \\--graph \\--oneline \\--all\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"\\* 03d23d0 Rename min\\_absolute to min\\_gb, use parameter names\n",
"\n",
"| \\* 42dc118 (origin/master, origin/HEAD) reorder conditional to match parameter order\n",
"\n",
"|/  \n",
"\n",
"| \\* 4d99c56 (origin/experimental, experimental) Empty check\\_load function\n",
"\n",
"|/  \n",
"\n",
"\\* 922d659 Add disk full check to all\\_checks.py\n",
"\n",
"\\* b62dc2e Add initial files for the checks\n",
"\n",
"\\* 807cb50 Add one more line to README.md\n",
"\n",
"\\* 3d9f86c Initial commit\n",
"\n",
"```bash\n",
"git log \\-p origin/master\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"commit a2dc1181e5cccf36fec30d6eeefbe569a13883de (origin/master, origin/HEAD)\n",
"\n",
"Author: Blue Kale <bluekale@example.com>\n",
"\n",
"Date:   Mon Jan 6 14:52:23 2020 -0800\n",
"\n",
"    Reorder conditional to match parameter order\n",
"\n",
"diff --git a/all\\_checks.py b/all\\_checks.py\n",
"\n",
"index e46cdae..6dda356 100755\n",
"\n",
"\\--- a/all\\_checks.py\n",
"\n",
"+++ b/all\\_checks.py\n",
"\n",
"@@ -15,7 +15,7 @@ def check\\_disk\\_full(disk, min\\_absolute, min\\_percent):\n",
"\n",
"     percent\\_free = 100 \\* du.free / du.total\n",
"\n",
"     # Calculate how many free gigabytes\n",
"\n",
"     gigabytes\\_free = du.free / 2\\*\\*30\n",
"\n",
"\\-    if percent\\_free < min\\_percent or gigabytes\\_free < min\\_absolute:\n",
"\n",
"+    if gigabytes\\_free < min\\_absolute or percent\\_free < min\\_percent:\n",
"\n",
"         return True\n",
"\n",
"     return False\n",
"\n",
"commit 922d65950b5325109525a24b71d8df8a46412d04 (HEAD -> master, origin/master, origin/HEAD)\n",
"\n",
"Author: Blue Kale <bluekale@example.com>\n",
"\n",
"Date:   Mon Jan 6 14:42:44 2020 -0800\n",
"\n",
"    Add disk full check to all\\_checks.py\n",
"\n",
"diff git a/all\\_checks.py b/all\\_checks.py\n",
"\n",
"```bash\n",
"atom all\\_checks.py\n",
"\n",
"#!/usr/binenv python3\n",
"\n",
"(...)\n",
"\n",
"def check\\_disk\\_full(disk, min\\_gb, min\\_percent):\n",
"\n",
"    \"\"\"Returns True if there isn't enough disk space, False otherwise.\"\"\"\n",
"\n",
"    du = shutil.disk\\_usage(disk)\n",
"\n",
"    # Calculate the percentage of free space\n",
"\n",
"    percent\\_free = 100 \\* du.free / du.total\n",
"\n",
"    # Calculate how many free gigabytes\n",
"\n",
"    gigabytes\\_free = du.free / 2\\*\\*30\n",
"\n",
"<<<<<<< HEAD\n",
"\n",
"    if percent\\_free < min\\_percent or gigabytes\\_free < min\\_gb:\n",
"\n",
"\\=======\n",
"\n",
"    if gigabytes\\_free < min\\_absolute or percent\\_free < min\\_percent:\n",
"\n",
"\\>>>>>>> a2dc1181e5cccf36fec30d6eeefbe569a13883de\n",
"\n",
"        return True\n",
"\n",
"    return False\n",
"\n",
"(...)\n",
"```\n",
"\n",
"```bash\n",
"(...)\n",
"\n",
"def check\\_disk\\_full(disk, min\\_gb, min\\_percent):\n",
"\n",
"    \"\"\"Returns True if there isn't enough disk space, False otherwise.\"\"\"\n",
"\n",
"    du = shutil.disk\\_usage(disk)\n",
"\n",
"    # Calculate the percentage of free space\n",
"\n",
"    percent\\_free = 100 \\* du.free / du.total\n",
"\n",
"    # Calculate how many free gigabytes\n",
"\n",
"    gigabytes\\_free = du.free / 2\\*\\*30\n",
"\n",
"    if gigabytes\\_free < min\\_gb or percent\\_free < min\\_percent:\n",
"\n",
"        return True\n",
"\n",
"    return False\n",
"\n",
"(...)\n",
"```\n",
"\n",
"```bash\n",
"git add all\\_checks.py \n",
"\n",
"git commit\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Merge branch 'master' of https://github.com/redquinoa/health-checks\n",
"\n",
"Fixed check\\_disk\\_usage conditional to use the new order and new variable name.\n",
"\n",
"\\# Conflicts:\n",
"\n",
"\\#       all\\_checks.py\n",
"\n",
"\\#\n",
"\n",
"(...)\n",
"\n",
"```bash\n",
"git push\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Enumerating objects: 10, done.\n",
"\n",
"Counting objects: 100% (10/10), done.\n",
"\n",
"Delta compression using up to 2 threads\n",
"\n",
"Compressing objects: 100% (6/6), done.\n",
"\n",
"Writing objects: 100% (6/6), 877 bytes | 877.00 KiB/s, done.\n",
"\n",
"Total 6 (delta 2), reused 0 (delta 0)\n",
"\n",
"remote: Resolving deltas: 100% (2/2), completed with 1 local object.\n",
"\n",
"To https://github.com/redquinoa/health-checks.git\n",
"\n",
"   a2dc118..58351ff  master -> master\n",
"\n",
"```bash\n",
"git log \\--graph \\--oneline\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"\\* 58351ff (Head -> master, origin/master, origin/HEAD) Merge branch master of https://github.com/redquinoa/health-checks.git\n",
"\n",
"|\\\\\n",
"\n",
"| \\* 42dc118 (origin/master, origin/HEAD) reorder conditional to match parameter order\n",
"\n",
"\\* | 03d23d0 Rename min\\_absolute to min\\_gb, use parameter names\n",
"\n",
"|/  \n",
"\n",
"| \\* 4d99c56 (origin/experimental, experimental) Empty check\\_load function\n",
"\n",
"|/  \n",
"\n",
"\\* 922d659 Add disk full check to all\\_checks.py\n",
"\n",
"\\* b62dc2e Add initial files for the checks\n",
"\n",
"\\* 807cb50 Add one more line to README.md\n",
"\n",
"\\* 3d9f86c Initial commit"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Pushing Remote Branches\n",
"\n",
"This reading contains the code used in the instructional videos from [**Pushing remote branches**<svg aria-labelledby=\"cds-react-aria3604314262-:r669:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r669:\"><title id=\"cds-react-aria3604314262-:r669:-title\">Opens in a new tab</title></svg>](https://www.coursera.org/learn/introduction-git-github/lecture/3AAD8/pushing-remote-branches)\n",
"\n",
"## Introduction\n",
"\n",
"This follow-along reading is organized to match the content in the video that follows. It contains the same code shown in the next video. These code blocks will provide you with the opportunity to see how the code is written and can be used as a reference as you work through the course.\n",
"\n",
"You can follow along in the reading as the instructor discusses the code or review the code after watching the video.\n",
"\n",
"```bash\n",
"git checkout \\-b refactor\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Switched to a new branch 'refactor'\n",
"\n",
"```bash\n",
"atom all\\_checks.py\n",
"\n",
"(...)\n",
"\n",
"def main():\n",
"\n",
"    if check\\_reboot():\n",
"\n",
"        print(\"Pending Reboot.\")\n",
"\n",
"        sys.exit(1)\n",
"\n",
"    if check\\_disk\\_full(disk=\"/\", min\\_gb=2, min\\_percent=10):\n",
"\n",
"        print(\"Disk full.\")\n",
"\n",
"        sys.exit(1)\n",
"\n",
"(...)\n",
"```\n",
"\n",
"```bash\n",
"(...)\n",
"\n",
"def check\\_root\\_full():\n",
"\n",
"    \"\"\"Returns True if the root partition is full, False otherwise.\"\"\"\n",
"\n",
"    return check\\_disk\\_full(disk=\"/\", min\\_gb=2, min\\_percent=10)\n",
"\n",
"def main():\n",
"\n",
"    if check\\_reboot():\n",
"\n",
"        print(\"Pending Reboot.\")\n",
"\n",
"        sys.exit(1)\n",
"\n",
"    if check\\_root\\_full():\n",
"\n",
"        print(\"Root partition full.\")\n",
"\n",
"        sys.exit(1)\n",
"\n",
"(...)\n",
"```\n",
"\n",
"```bash\n",
"./all\\_checks.py \n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Everything ok.\n",
"\n",
"```bash\n",
"git commit \\-a \\-m 'Create wrapper function for check\\_disk\\_full'\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"\\[refactor e914aee\\] Create wrapper function for check\\_disk\\_full\n",
"\n",
" 1 file changed, 8 insertions(+), 2 deletions(-)\n",
"\n",
"```bash\n",
"(...)\n",
"\n",
"def check\\_root\\_full():\n",
"\n",
"    \"\"\"Returns True if the root partition is full, False otherwise.\"\"\"\n",
"\n",
"    return check\\_disk\\_full(disk=\"/\", min\\_gb=2, min\\_percent=10)\n",
"\n",
"def main():\n",
"\n",
"    checks = \\[\n",
"\n",
"            (check\\_reboot, \"Pending Reboot.\"),\n",
"\n",
"            (check\\_root\\_full, \"Root partition full\"),\n",
"\n",
"            \\]\n",
"\n",
"    for check, msg in checks:\n",
"\n",
"        if check():\n",
"\n",
"            print(msg)\n",
"\n",
"            sys.exit(1)\n",
"\n",
"    print(\"Everything ok.\")\n",
"\n",
"    sys.exit(0)\n",
"\n",
"(...)\n",
"```\n",
"\n",
"```bash\n",
"./all\\_checks.py \n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Everything ok.\n",
"\n",
"```bash\n",
"git commit \\-a \\-m 'Iterate over a list of checks and messages to avoid code duplication'\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"\\[refactor 75bdd43\\] Iterate over a list of checks and messages to avoid code duplication\n",
"\n",
" 1 file changed, 8 insertions(+), 6 deletions(-)\n",
"\n",
"```bash\n",
"(...)    \n",
"\n",
"def main():\n",
"\n",
"    checks = \\[\n",
"\n",
"            (check\\_reboot, \"Pending Reboot.\"),\n",
"\n",
"            (check\\_root\\_full, \"Root partition full\"),\n",
"\n",
"            \\]\n",
"\n",
"everything\\_ok = True\n",
"\n",
"    for check, msg in checks:\n",
"\n",
"        if check():\n",
"\n",
"            print(msg)\n",
"\n",
"            everything\\_ok = False\n",
"\n",
"    if not everything\\_ok:\n",
"\n",
"        sys.exit(1)\n",
"\n",
"    print(\"Everything ok.\")\n",
"\n",
"   sys.exit(0)\n",
"\n",
"(...)\n",
"```\n",
"\n",
"```bash\n",
"./all\\_checks.py \n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Everything ok.\n",
"\n",
"```bash\n",
"git commit \\-a \\-m 'Allow printing more than one error message'\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"\\[refactor cbee3f7\\] Allow printing more than one error message\n",
"\n",
" 1 file changed, 7 insertions(+), 1 deletion(-)\n",
"\n",
"```bash\n",
"git push \\-u origin refactor\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Username for 'https://github.com': redquinoa\n",
"\n",
"Password for 'https://redquinoa@github.com': \n",
"\n",
"Enumerating objects: 11, done.\n",
"\n",
"Counting objects: 100% (11/11), done.\n",
"\n",
"Delta compression using up to 4 threads\n",
"\n",
"Compressing objects: 100% (9/9), done.\n",
"\n",
"Writing objects: 100% (9/9), 1.34 KiB | 1.34MiB/s, done.\n",
"\n",
"Total 9 (delta 3), reused 0 (delta 0)\n",
"\n",
"remote: Resolving deltas: 100% (3/3), completed with 1 local object.\n",
"\n",
"remote: \n",
"\n",
"remote: Create a pull request for 'refactor' on GitHub by visiting:\n",
"\n",
"remote:      https://github.com/redquinoa/health-checks/pull/new/refactor\n",
"\n",
"remote: \n",
"\n",
"To https://github.com/redquinoa/health-checks.git\n",
"\n",
" \\* \\[new branch\\]      refactor -> refactor\n",
"\n",
"Branch 'refactor' set up to track remote branch 'refactor' from 'origin'."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Rebasing Your Changes\n",
"\n",
"This reading contains the code used in the instructional videos from [**Rebasing Your Changes**<svg aria-labelledby=\"cds-react-aria3604314262-:r6gv:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria3604314262-:r6gv:\"><title id=\"cds-react-aria3604314262-:r6gv:-title\">Opens in a new tab</title></svg>](https://www.coursera.org/learn/introduction-git-github/lecture/cEqbt/rebasing-your-changes)\n",
"\n",
"##  Introduction\n",
"\n",
"This follow-along reading is organized to match the content in the video that follows. It contains the same code shown in the next video. These code blocks will provide you with the opportunity to see how the code is written and can be used as a reference as you work through the course.\n",
"\n",
"You can follow along in the reading as the instructor discusses the code or review the code after watching the video.\n",
"\n",
"```bash\n",
"git checkout master\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Switched to branch 'master'\n",
"\n",
"Your branch is up to date with 'origin/master'.\n",
"\n",
"```bash\n",
"git pull\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Remote: Enumerating objects: 5, done. \n",
"\n",
"Remote: Counting objects: 100% (5/5), done. \n",
"\n",
"Remote: Total 3 (delta 1), reused 3 (delta 1), pack-reused 0\n",
"\n",
"Unpacking objects: 10% (3/3), done. \n",
"\n",
"From https://github.com/redquinoa/healthchecks\n",
"\n",
"    58351ff..0789f64  master    -> origin/master\n",
"\n",
"Updating 58351ff..0789f64\n",
"\n",
"Fast-forward\n",
"\n",
" README.md | 2 ++\n",
"\n",
" 1 file changed, 2 insertions(+)\n",
"\n",
"```bash\n",
"git log \\--graph \\--oneline \\--all\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"\\* 0789f64 (HEAD -> master, origin/master, origin/HEAD) Add reference to all\\_checks.py to README\n",
"\n",
"| \\* cbee3f7 (origin/refactor, refactor) Allow printing more than one error message\n",
"\n",
"| \\* 75bdd43 Iterate over a list of checks and messages to avoid code duplication\n",
"\n",
"| \\* e914aee Create wrapper function for check\\_disk\\_full\n",
"\n",
"|/  \n",
"\n",
"\\*   58351ff Merge branch 'master' of https://github.com/redquinoa/health-checks\n",
"\n",
"|\\\\  \n",
"\n",
"| \\* a2dc118 Reorder conditional to match parameter order\n",
"\n",
"\\* | 03d23d0 Rename min\\_absolute to min\\_gb, use parameter names\n",
"\n",
"|/  \n",
"\n",
"| \\* 4d99c56 (origin/experimental, experimental) Empty check\\_load function\n",
"\n",
"|/  \n",
"\n",
"\\* 922d659 Add disk full check to all\\_checks.py\n",
"\n",
"\\* b62dc2e Add initial files for the checks\n",
"\n",
"\\* 807cb50 Add one more line to README.md\n",
"\n",
"\\* 3d9f86c Initial commit\n",
"\n",
"```bash\n",
"git checkout refactor\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Switched to branch 'refactor'\n",
"\n",
"Your branch is up to date with 'origin/refactor'.\n",
"\n",
"```bash\n",
"git rebase master\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"First, rewinding head to replay your work on top of it...\n",
"\n",
"Applying: Create wrapper function for check\\_disk\\_full\n",
"\n",
"Applying: Iterate over a list of checks and messages to avoid code duplication\n",
"\n",
"Applying: Allow printing more than one error message\n",
"\n",
"```bash\n",
"git log \\--graph \\--oneline\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"\\* f5813b1 (HEAD -> refactor) Allow printing more than one error message\n",
"\n",
"\\* 18257a0 Iterate over a list of checks and messages to avoid code duplication\n",
"\n",
"\\* e914aee Create wrapper function for check\\_disk\\_full\n",
"\n",
"\\* 0789f64 (origin/master, origin/HEAD, master) Add reference to all\\_checks.py to README\n",
"\n",
"\\*   58351ff Merge branch 'master' of https://github.com/redquinoa/health-checks\n",
"\n",
"|\\\\  \n",
"\n",
"| \\* a2dc118 Reorder conditional to match parameter order\n",
"\n",
"\\* | 03d23d0 Rename min\\_absolute to min\\_gb, use parameter names\n",
"\n",
"|/  \n",
"\n",
"\\* 922d659 Add disk full check to all\\_checks.py\n",
"\n",
"\\* b62dc2e Add initial files for the checks\n",
"\n",
"\\* 807cb50 Add one more line to README.md\n",
"\n",
"\\* 3d9f86c Initial commit\n",
"\n",
"```bash\n",
"git checkout master\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Switched to branch 'master'\n",
"\n",
"Your branch is up to date with 'origin/master'.\n",
"\n",
"```bash\n",
"git merge refactor\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Updating 0789f64..f5813b1\n",
"\n",
"Fast-forward\n",
"\n",
" all\\_checks.py | 24 +++++++++++++++++-----\n",
"\n",
" 1 file changed, 19 insertions(+), 5 deletions(-)\n",
"\n",
"```bash\n",
"git push \\--delete origin refactor\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Username for 'https://github.com': redquinoa\n",
"\n",
"Password for 'https://redquinoa@github.com': \n",
"\n",
"To https://github.com/redquinoa/health-checks.git\n",
"\n",
" - \\[deleted\\]         refactor\n",
"\n",
"```bash\n",
"git branch \\-d refactor\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Deleted branch refactor (was f5813b1).\n",
"\n",
"```bash\n",
"git push\n",
"```\n",
"\n",
"**Code output:** \n",
"\n",
"Enumerating objects: 11, done.\n",
"\n",
"Counting objects: 100% (11/11), done.\n",
"\n",
"Delta compression using up to 4 threads\n",
"\n",
"Compressing objects: 100% (9/9), done.\n",
"\n",
"Writing objects: 100% (9/9), 1.37 KiB | 1.37 MiB/s, done.\n",
"\n",
"Total 9 (delta 3), reused 0 (delta 0)\n",
"\n",
"remote: Resolving deltas: 100% (3/3), completed with 1 local object.\n",
"\n",
"To https://github.com/red-quinoa/health-checks.git\n",
"\n",
"   0789f64..f5813b1  master -> master"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Another Rebasing Example\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Study guide: Conflict resolution\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Glossary terms from module 3\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Exemplar: Introduction to GitHub"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}