From 9da96328e7ffcc5edb98353819aede8b1ef295f2 Mon Sep 17 00:00:00 2001 From: ocasarez Date: Mon, 3 Feb 2020 22:35:45 -0800 Subject: [PATCH] Added amend command section --- README.md | 26 ++++++++++++++++++++++++-- temp.txt | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 temp.txt diff --git a/README.md b/README.md index 5e9e700..0e85a2f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ You will use these same skills throughout your projects for handling code review ## Learning Objectives ## - Learn GitHub basics: how to fork, submit a pull request, and assign code reviewers -- Learn `git` basics: how to `clone`, `branch`, `commit`, `push`, and `pull` +- Learn `git` basics: how to `clone`, `branch`, `commit`, `ammend`, `push`, and `pull` ----------- @@ -251,7 +251,6 @@ On subsequent runs, `git` will default to using the `origin` remote for the `upd ```console git push ``` - ### Step 8: Submit a Pull Request ### Almost everything discussed so far has been about selective isolation of your code from the rest of the codebase. @@ -284,6 +283,29 @@ Your name and description should concisely describe the changes you've made. Once you write the name and description, click the green `Create pull request` button again, which will submit the pull request. In the next assignment, we'll work with these submitted pull requests for code reviewing purposes. +## Bonus Tip: Making Amendments to Commits ## + +If at any point you want to undo something due to a mistake such as, forgetting to add some files or messing up the commit message you can use `--amend`. +If you just want to edit the commit message it can be done with the following command: + +```console +git commit --amend +``` + +Running this single command will take your staged files and use it for the commit but open the commit-message editor to change the commit message. +The commit made using `amend` will **overwrite** the previous commit so you must be very careful. +Additionally, if you want to add files you forgot to stage then you want to add this to the commit: + +```console +git commit -m 'initial commit' +git add forgotten_file +git commit --amend +``` + +The previous, commit will be overwritten and you will end up with a single commit. +It is important to note that `ammend` does not fix the previous commit it effectively replaces it, as if the previous commit never happened. + + ## Retrospective ## In this assignment, you've gone over some basics of using `git` and GitHub. diff --git a/temp.txt b/temp.txt new file mode 100644 index 0000000..c59ee1b --- /dev/null +++ b/temp.txt @@ -0,0 +1 @@ +COMP 587: Assignment 1 \ No newline at end of file