update module2.ipynb
This commit is contained in:
parent
e3a6dae00c
commit
11dd0f55af
364
module2.ipynb
364
module2.ipynb
@ -1,5 +1,367 @@
|
||||
{
|
||||
"cells": [],
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Skipping the Staging Area\n",
|
||||
"\n",
|
||||
"This reading contains the code used in the instructional videos from [**Skipping the Staging Area**<svg aria-labelledby=\"cds-react-aria6078214324-:r1pi:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria6078214324-:r1pi:\"><title id=\"cds-react-aria6078214324-:r1pi:-title\">Opens in a new tab</title></svg>](https://www.coursera.org/learn/introduction-git-github/lecture/uAFPm/skipping-the-staging-area).\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 scripts\n",
|
||||
"\n",
|
||||
"atom all\\_checks.py\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"## File with code\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"#!/usr/bin/env python3\n",
|
||||
"\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"import sys\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 main():\n",
|
||||
"\n",
|
||||
" if check\\_reboot():\n",
|
||||
"\n",
|
||||
" print(\"Pending Reboot.\")\n",
|
||||
"\n",
|
||||
" sys.exit(1)\n",
|
||||
"\n",
|
||||
"main()\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git commit \\-a \\-m \"Call check\\_reboot from main, exit with 1 on error\"\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"\\[master 033f27a\\] Call check\\_reboot from main, exit with 1 on error\n",
|
||||
"\n",
|
||||
" 1 file changed, 4 insertions(+), 1 deletion(-)\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git log\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"commit 033f27a8196987d61c4fd42930f2148b23434a03 (HEAD -> master)\n",
|
||||
"\n",
|
||||
"Author: My name <me@example.com>\n",
|
||||
"\n",
|
||||
"Date: Mon Jul 15 14:39:18 2019 +0200\n",
|
||||
"\n",
|
||||
" Call check\\_reboot from main, exit with 1 on error\n",
|
||||
"\n",
|
||||
"commit cc1acbf10fdea6cc07ebf827697666b6a35b0f36\n",
|
||||
"\n",
|
||||
"Author: My name <me@example.com>\n",
|
||||
"\n",
|
||||
"Date: Thu Jul 11 17:19:32 2019 +0200\n",
|
||||
"\n",
|
||||
" Add a check\\_reboot function\n",
|
||||
"\n",
|
||||
"commit 6cfc29966acda8213fcd8ac2735b31f3fdbc6c53\n",
|
||||
"\n",
|
||||
"Author: My name <me@example.com>\n",
|
||||
"\n",
|
||||
"Date: Thu Jul 11 12:08:46 2019 +0200\n",
|
||||
"\n",
|
||||
" Create and empty all\\_checks.py"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Getting more information from the user\n",
|
||||
"\n",
|
||||
"This reading contains the code used in the instructional videos from [**Getting More Information About Our Changes**<svg aria-labelledby=\"cds-react-aria6078214324-:r224:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria6078214324-:r224:\"><title id=\"cds-react-aria6078214324-:r224:-title\">Opens in a new tab</title></svg>](https://www.coursera.org/learn/introduction-git-github/lecture/KLQkB/getting-more-information-about-our-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 log \\-p\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"commit 033f27a8196987d61c4fd42930f2148b23434a03 (HEAD -> master)\n",
|
||||
"\n",
|
||||
"Author: My name <me@example.com>\n",
|
||||
"\n",
|
||||
"Date: Mon Jul 15 14:39:18 2019 +0200\n",
|
||||
"\n",
|
||||
" Call check\\_reboot from main, exit with 1 on error\n",
|
||||
"\n",
|
||||
"diff --git a/all\\_checks.py b/all\\_checks.py\n",
|
||||
"\n",
|
||||
"index 340f1f7..710266a 100644\n",
|
||||
"\n",
|
||||
"\\--- a/all\\_checks.py\n",
|
||||
"\n",
|
||||
"+++ b/all\\_checks.py\n",
|
||||
"\n",
|
||||
"@@ -1,12 +1,15 @@\n",
|
||||
"\n",
|
||||
" #!/usr/bin/env python3\n",
|
||||
"\n",
|
||||
" import os\n",
|
||||
"\n",
|
||||
"+import sys\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",
|
||||
"(...)\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git log\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"commit 033f27a8196987d61c4fd42930f2148b23434a03 (HEAD -> master)\n",
|
||||
"\n",
|
||||
"Author: My name <me@example.com>\n",
|
||||
"\n",
|
||||
"Date: Mon Jul 15 14:39:18 2019 +0200\n",
|
||||
"\n",
|
||||
" Call check\\_reboot from main, exit with 1 on error\n",
|
||||
"\n",
|
||||
"commit **cc1acbf10fdea6cc07ebf827697666b6a35b0f36**\n",
|
||||
"\n",
|
||||
"Author: My name <me@example.com>\n",
|
||||
"\n",
|
||||
"Date: Thu Jul 11 17:19:32 2019 +0200\n",
|
||||
"\n",
|
||||
" Add a check\\_reboot function\n",
|
||||
"\n",
|
||||
"(...)\n",
|
||||
"\n",
|
||||
"user@ubuntu:~/scripts$ git show cc1acbf10fdea6cc07ebf827697666b6a35b0f36\n",
|
||||
"\n",
|
||||
"commit cc1acbf10fdea6cc07ebf827697666b6a35b0f36\n",
|
||||
"\n",
|
||||
"Author: My name <me@example.com>\n",
|
||||
"\n",
|
||||
"Date: Thu Jul 11 17:19:32 2019 +0200\n",
|
||||
"\n",
|
||||
" Add a check\\_reboot function\n",
|
||||
"\n",
|
||||
"diff --git a/all\\_checks.py b/all\\_checks.py\n",
|
||||
"\n",
|
||||
"index c0d03b3..340f1f7 100644\n",
|
||||
"\n",
|
||||
"\\--- a/all\\_checks.py\n",
|
||||
"\n",
|
||||
"+++ b/all\\_checks.py\n",
|
||||
"\n",
|
||||
"@@ -1,5 +1,11 @@\n",
|
||||
"\n",
|
||||
" #!/usr/bin/env python3\n",
|
||||
"\n",
|
||||
"+import os\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",
|
||||
"+\n",
|
||||
"\n",
|
||||
" def main():\n",
|
||||
"\n",
|
||||
" Pass\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git log \\--stat\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"commit 033f27a8196987d61c4fd42930f2148b23434a03 (HEAD -> master)\n",
|
||||
"\n",
|
||||
"Author: My name <me@example.com>\n",
|
||||
"\n",
|
||||
"Date: Mon Jul 15 14:39:18 2019 +0200\n",
|
||||
"\n",
|
||||
" Call check\\_reboot from main, exit with 1 on error\n",
|
||||
"\n",
|
||||
" all\\_checks.py | 5 ++++-\n",
|
||||
"\n",
|
||||
" 1 file changed, 4 insertions(+), 1 deletion(-)\n",
|
||||
"\n",
|
||||
"(...)\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"atom all\\_checks.py\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"## File in video\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"#!/usr/bin/env python3\n",
|
||||
"\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"import sys\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 main():\n",
|
||||
"\n",
|
||||
" if check\\_reboot():\n",
|
||||
"\n",
|
||||
" print(\"Pending Reboot.\")\n",
|
||||
"\n",
|
||||
" sys.exit(1)\n",
|
||||
"\n",
|
||||
" print(\"Everything ok.\")\n",
|
||||
"\n",
|
||||
" sys.exit(0)\n",
|
||||
"\n",
|
||||
"main()\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git diff\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"diff --git a/all\\_checks.py b/all\\_checks.py\n",
|
||||
"\n",
|
||||
"index 710266a..fdc4476 100644\n",
|
||||
"\n",
|
||||
"\\--- a/all\\_checks.py\n",
|
||||
"\n",
|
||||
"+++ b/all\\_checks.py\n",
|
||||
"\n",
|
||||
"@@ -12,4 +12,7 @@ def main():\n",
|
||||
"\n",
|
||||
" print(\"Pending Reboot.\")\n",
|
||||
"\n",
|
||||
" sys.exit(1)\n",
|
||||
"\n",
|
||||
"+ print(\"Everything ok.\")\n",
|
||||
"\n",
|
||||
"+ sys.exit(0)\n",
|
||||
"\n",
|
||||
"+\n",
|
||||
"\n",
|
||||
" main()\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 710266a..fdc4476 100644\n",
|
||||
"\n",
|
||||
"\\--- a/all\\_checks.py\n",
|
||||
"\n",
|
||||
"+++ b/all\\_checks.py\n",
|
||||
"\n",
|
||||
"@@ -12,4 +12,7 @@ def main():\n",
|
||||
"\n",
|
||||
" print(\"Pending Reboot.\")\n",
|
||||
"\n",
|
||||
" sys.exit(1)\n",
|
||||
"\n",
|
||||
"+ print(\"Everything ok.\")\n",
|
||||
"\n",
|
||||
"+ sys.exit(0)\n",
|
||||
"\n",
|
||||
"+\n",
|
||||
"\n",
|
||||
" main()\n",
|
||||
"\n",
|
||||
"Stage this hunk \\[y,n,q,a,d,e,?\\]? y\n",
|
||||
"\n",
|
||||
"user@ubuntu:~/scripts$ \n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git diff\n",
|
||||
"\n",
|
||||
"git diff \\--staged\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"diff --git a/all\\_checks.py b/all\\_checks.py\n",
|
||||
"\n",
|
||||
"index 710266a..fdc4476 100644\n",
|
||||
"\n",
|
||||
"\\--- a/all\\_checks.py\n",
|
||||
"\n",
|
||||
"+++ b/all\\_checks.py\n",
|
||||
"\n",
|
||||
"@@ -12,4 +12,7 @@ def main():\n",
|
||||
"\n",
|
||||
" print(\"Pending Reboot.\")\n",
|
||||
"\n",
|
||||
" sys.exit(1)\n",
|
||||
"\n",
|
||||
"+ print(\"Everything ok.\")\n",
|
||||
"\n",
|
||||
"+ sys.exit(0)\n",
|
||||
"\n",
|
||||
"+\n",
|
||||
"\n",
|
||||
" main()\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git commit \\-m 'Add a message when everything is ok'\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"\\[master 49d610b\\] Add a message when everything is ok\n",
|
||||
"\n",
|
||||
" 1 file changed, 3 insertions(+)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
|
Loading…
Reference in New Issue
Block a user