update module2.ipynb
This commit is contained in:
parent
3c9b7e493b
commit
f31df72cb6
143
module2.ipynb
143
module2.ipynb
@ -521,7 +521,141 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# "
|
||||
"# Undoing Changes Before Committing\n",
|
||||
"\n",
|
||||
"This reading contains the code used in the instructional videos from [**Undoing changes before committing**<svg aria-labelledby=\"cds-react-aria2659598955-:r97:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria2659598955-:r97:\"><title id=\"cds-react-aria2659598955-:r97:-title\">Opens in a new tab</title></svg>](https://www.coursera.org/learn/introduction-git-github/lecture/LPJn7/undoing-changes-before-committing)\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 in video\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"#!/usr/bin/env python3\n",
|
||||
"\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"import sys\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",
|
||||
"./all\\_checks.py \n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"Traceback (most recent call last):\n",
|
||||
"\n",
|
||||
" File \"all\\_checks.py\", line 14, in <module>\n",
|
||||
"\n",
|
||||
" main()\n",
|
||||
"\n",
|
||||
" File \"all\\_checks.py\", line 7, in main\n",
|
||||
"\n",
|
||||
" if check\\_reboot():\n",
|
||||
"\n",
|
||||
"NameError: name 'check\\_reboot' is not defined\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git status\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"On branch master\n",
|
||||
"\n",
|
||||
"Changes not staged for commit:\n",
|
||||
"\n",
|
||||
" (use \"git add <file>...\" to update what will be committed)\n",
|
||||
"\n",
|
||||
" (use \"git checkout -- <file>...\" to discard changes in working directory)\n",
|
||||
"\n",
|
||||
" modified: all\\_checks.py\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git checkout all\\_checks.py\n",
|
||||
"\n",
|
||||
"git status\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"On branch master\n",
|
||||
"\n",
|
||||
"nothing to commit, working tree clean\n",
|
||||
"\n",
|
||||
"user@ubuntu:~/scripts$ ./all\\_checks.py \n",
|
||||
"\n",
|
||||
"Everything ok.\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"./all\\_checks.py \n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"Everything ok.\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"./all\\_checks.py > output.txt\n",
|
||||
"\n",
|
||||
"git add \\*\n",
|
||||
"\n",
|
||||
"git status\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"On branch master\n",
|
||||
"\n",
|
||||
"Changes to be committed:\n",
|
||||
"\n",
|
||||
" (use \"git reset HEAD <file>...\" to unstage)\n",
|
||||
"\n",
|
||||
" new file: output.txt\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git reset HEAD output.txt\n",
|
||||
"\n",
|
||||
"git status\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"On branch master\n",
|
||||
"\n",
|
||||
"Untracked files:\n",
|
||||
"\n",
|
||||
" (use \"git add <file>...\" to include in what will be committed)\n",
|
||||
"\n",
|
||||
" Output.txt\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git commit \\-m \"it should be os.path.exists\"\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -530,6 +664,11 @@
|
||||
"source": [
|
||||
"# "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
@ -540,7 +679,7 @@
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python",
|
||||
"version": "3.12.3"
|
||||
"version": "3.13.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
Loading…
Reference in New Issue
Block a user