update module4.ipynb
This commit is contained in:
parent
1d7da3362a
commit
fa1f6cd6b1
248
module4.ipynb
248
module4.ipynb
@ -220,14 +220,258 @@
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Squashing Changes"
|
||||
"# Squashing Changes\n",
|
||||
"\n",
|
||||
"This reading contains the code used in the instructional videos from [**Squashing Changes**<svg aria-labelledby=\"cds-react-aria1005828919-:r15d:-title\" fill=\"none\" focusable=\"false\" height=\"16\" role=\"img\" viewBox=\"0 0 20 20\" width=\"16\" class=\"css-8blerm\" id=\"cds-react-aria1005828919-:r15d:\"><title id=\"cds-react-aria1005828919-:r15d:-title\">Opens in a new tab</title></svg>](https://www.coursera.org/learn/introduction-git-github/lecture/6ODVl/squashing-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 rebase \\-i master\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"pick 736d754 Add a simple README file\n",
|
||||
"\n",
|
||||
"pick 01231b0 Add more information to the README\n",
|
||||
"\n",
|
||||
"(...)\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"pick 736d754 Add a simple README file\n",
|
||||
"\n",
|
||||
"squash 01231b0 Add more information to the README\n",
|
||||
"\n",
|
||||
"(...)\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"# This is a combination of 2 commits. \n",
|
||||
"\n",
|
||||
"# This is the 1st commit message:\n",
|
||||
"\n",
|
||||
"Add a simple README file\n",
|
||||
"\n",
|
||||
"# This is the commit message #2:\n",
|
||||
"\n",
|
||||
"Add more information to the README\n",
|
||||
"\n",
|
||||
"(...)\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"# This is a combination of 2 commits. \n",
|
||||
"\n",
|
||||
"# This is the 1st commit message:\n",
|
||||
"\n",
|
||||
"Add a simple README file including an example use case\n",
|
||||
"\n",
|
||||
"# This is the commit message #2:\n",
|
||||
"\n",
|
||||
"Add more information to the README\n",
|
||||
"\n",
|
||||
"(...)\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:** \n",
|
||||
"\n",
|
||||
"git rebase -i master\n",
|
||||
"\n",
|
||||
"\\[detached HEAD ae779e4\\] Add a simple README.md file including an example use case\n",
|
||||
"\n",
|
||||
" Date: Tue Jan 7 09:47:17 2020 -0800\n",
|
||||
"\n",
|
||||
" 1 file changed, 9 insertions(+)\n",
|
||||
"\n",
|
||||
" create mode 100644 README.md\n",
|
||||
"\n",
|
||||
"Successfully rebased and updated refs/heads/add-readme.\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git show\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"commit ae779e430288b082a19062ed087c547e1051a981 (HEAD -> add-readme)\n",
|
||||
"\n",
|
||||
"Author: My name <me@example.com>\n",
|
||||
"\n",
|
||||
"Date: Tue Jan 7 09:47:17 2020 -0800\n",
|
||||
"\n",
|
||||
" Add a simple README file including an example use case\n",
|
||||
"\n",
|
||||
"diff --git a/README.md b/README.md\n",
|
||||
"\n",
|
||||
"new file mode 100644\n",
|
||||
"\n",
|
||||
"index 0000000..5761a46\n",
|
||||
"\n",
|
||||
"\\--- /dev/null\n",
|
||||
"\n",
|
||||
"+++ b/README.md\n",
|
||||
"\n",
|
||||
"@@ -0,0 +1,9 @@\n",
|
||||
"\n",
|
||||
"+Rearrange\n",
|
||||
"\n",
|
||||
"+=========\n",
|
||||
"\n",
|
||||
"+\n",
|
||||
"\n",
|
||||
"+This module is used for rearranging names.\n",
|
||||
"\n",
|
||||
"+Turns \"LastName, FirstName\" into \"FirstName LastName\"\n",
|
||||
"\n",
|
||||
"+\n",
|
||||
"\n",
|
||||
"+# Example\n",
|
||||
"\n",
|
||||
"+\n",
|
||||
"\n",
|
||||
"+Calling \\`rearrange\\_name(\"Turing, Alan\")\\` will return \\`\"Alan Turing\"\\`\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git status\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"On branch add-readme\n",
|
||||
"\n",
|
||||
"Your branch and 'origin/add-readme' have diverged,\n",
|
||||
"\n",
|
||||
"and have 1 and 2 different commits each, respectively.\n",
|
||||
"\n",
|
||||
" (use \"git pull\" to merge the remote branch into yours)\n",
|
||||
"\n",
|
||||
"nothing to commit, working tree clean\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git log \\--graph \\--oneline \\--all \\-4\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"\\* ae779e4 (HEAD -> add-readme) Add a simple README.md file including an example use case\n",
|
||||
"\n",
|
||||
"| \\* 01231b0 (origin/add-readme) Add more information to the README\n",
|
||||
"\n",
|
||||
"| \\* 736d754 Add a simple README.md file\n",
|
||||
"\n",
|
||||
"|/ \n",
|
||||
"\n",
|
||||
"\\* 367a127 (origin/master, origin/HEAD, master) Add tests for the rearrange module\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': redquinoa\n",
|
||||
"\n",
|
||||
"To https://github.com/redquinoa/rearrange.git\n",
|
||||
"\n",
|
||||
" ! \\[rejected\\] add-readme -> add-readme (non-fast-forward)\n",
|
||||
"\n",
|
||||
"error: failed to push some refs to 'https://github.com/redquinoa/rearrange.git'\n",
|
||||
"\n",
|
||||
"hint: Updates were rejected because the tip of your current branch is behind\n",
|
||||
"\n",
|
||||
"hint: its remote counterpart. Integrate the remote changes (e.g.\n",
|
||||
"\n",
|
||||
"hint: '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 push \\-f\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"Enumerating objects: 4, done.\n",
|
||||
"\n",
|
||||
"Counting objects: 100% (4/4), done.\n",
|
||||
"\n",
|
||||
"Delta compression using up to 4 threads\n",
|
||||
"\n",
|
||||
"Compressing objects: 100% (3/3), done.\n",
|
||||
"\n",
|
||||
"Writing objects: 100% (3/3), 510 bytes | 510.00 KiB/s, done.\n",
|
||||
"\n",
|
||||
"Total 3 (delta 0), reused 0 (delta 0)\n",
|
||||
"\n",
|
||||
"To https://github.com/redquinoa/rearrange.git\n",
|
||||
"\n",
|
||||
" + 01231b0...ae779e4 add-readme -> add-readme (forced update)\n",
|
||||
"\n",
|
||||
"```bash\n",
|
||||
"git log \\--graph \\--oneline \\--all \\-4\n",
|
||||
"```\n",
|
||||
"\n",
|
||||
"**Code output:**\n",
|
||||
"\n",
|
||||
"\\* ae779e4 (HEAD -> add-readme, origin/add-readme) Add a simple README.md file including an example use case\n",
|
||||
"\n",
|
||||
"\\* 367a127 (origin/master, origin/HEAD, master) Add tests for the rearrange module\n",
|
||||
"\n",
|
||||
"\\* c89805e Add the rearrange module\n",
|
||||
"\n",
|
||||
"\\* f4ddbc7 Initial commit"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Study guide: Git forks and pull requests"
|
||||
"# Study guide: Git forks and pull requests\n",
|
||||
"\n",
|
||||
"GitHub is an open-source platform for collaboration and knowledge sharing, allowing users to explore code created by others. This study guide will provide you with pointers on effectively using the platform to make pull requests in the Git environment.\n",
|
||||
"\n",
|
||||
"## Pull requests\n",
|
||||
"\n",
|
||||
"Pull requests allow you to inform fellow contributors about changes that have been made to a branch in Git. When pulling requests, you can discuss and evaluate proposed changes before implementing changes to the primary branch.\n",
|
||||
"\n",
|
||||
"You can eventually merge changes back into the main repository (or repo) by creating a pull request. However, it is important to note that before any changes are made to the original code, GitHub creates a fork (or a copy of the project), which allows changes to be committed to the fork copy even if changes cannot be pushed to the other repo. Anyone can suggest changes through the inline comment in pull requests, but the owner only has rights to review and approve changes before merging them. To create a pull request:\n",
|
||||
"\n",
|
||||
"- Make changes to the file.\n",
|
||||
"- Change the proposal and complete a description of the change.\n",
|
||||
"- Click the Proposed File Change button to create a commit in the forked repo to send the change to the owner.\n",
|
||||
"- Enter comments about the change. If more context is needed about the change, use the text box.\n",
|
||||
"- Click Pull Request.\n",
|
||||
"\n",
|
||||
"When creating multiple commits, a number next to the pull request serves as the identifier for accessing the pull requests in the future. This is important because it allows project maintainers to follow up with questions or comments. \n",
|
||||
"\n",
|
||||
"For more information on creating pull requests, click the following link: [Creating a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request)\n",
|
||||
"\n",
|
||||
"## Pull request merges\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"You can merge pull requests by retaining the commits. Below is a list of pull request merge options that you can use when merging pull requests.\n",
|
||||
"\n",
|
||||
"**Merge commits.** All commits from the feature branch are added to the base branch in a merge commit using the -- no–ff option. \n",
|
||||
"\n",
|
||||
"**Squash and merge commits.** Multiple commits of a pull request are squashed, or combined into a single commit, using the fast-forward option. It is recommended that when merging two branches, pull requests are squashed and merged to prevent the likelihood of conflicts due to redundancy.\n",
|
||||
"\n",
|
||||
"**Merge message for a squash merge.** GitHub generates a default commit message, which you can edit. This message may include the pull request title, pull request description, or information about the commits.\n",
|
||||
"\n",
|
||||
"**Rebase and merge commits.** All commits from the topic branch are added onto the base branch individually without a merge commit. \n",
|
||||
"\n",
|
||||
"**Indirect merges.** GitHub can merge a pull request automatically if the head branch is directly or indirectly merged into the base branch externally.\n",
|
||||
"\n",
|
||||
"## Key takeaways\n",
|
||||
"\n",
|
||||
"Pull requests are a crucial tool you can use for efficiently capturing, implementing, and receiving approvals for changes. These capabilities are made possible through collaboration. Practicing pull requests can help you hone your skills and contribute to a project."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user