From 1b53b5ea34d6109bad8484c36ba7217e60745ec6 Mon Sep 17 00:00:00 2001 From: danitellini Date: Tue, 17 Dec 2024 18:14:39 -0300 Subject: [PATCH 1/6] metadata entered --- content/git/concepts/amend/amend.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 content/git/concepts/amend/amend.md diff --git a/content/git/concepts/amend/amend.md b/content/git/concepts/amend/amend.md new file mode 100644 index 00000000000..76407b1bb6f --- /dev/null +++ b/content/git/concepts/amend/amend.md @@ -0,0 +1,16 @@ +--- +Title: 'Amend' +Description: 'Modifies the most recent Git commit without creating a new one.' +Subjects: + - 'Bash/Shell' + - 'Developer Tools' +Tags: + - 'Command Line' + - 'Documentation' + - 'Error Handling' + - 'Git' + - 'Version Control' +CatalogContent: + - 'learn-git' + - 'paths/computer-science' +--- From 2c76d811591f68c539e5ae604fb2128361f8f6c0 Mon Sep 17 00:00:00 2001 From: danitellini Date: Tue, 17 Dec 2024 18:40:24 -0300 Subject: [PATCH 2/6] draft amend entry - ready for pr --- content/git/concepts/amend/amend.md | 80 +++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/content/git/concepts/amend/amend.md b/content/git/concepts/amend/amend.md index 76407b1bb6f..9dca5ab5970 100644 --- a/content/git/concepts/amend/amend.md +++ b/content/git/concepts/amend/amend.md @@ -14,3 +14,83 @@ CatalogContent: - 'learn-git' - 'paths/computer-science' --- + +**Amend** is a Git feature that modifies the most recent commit. It allows developers to correct mistakes such as a missing file, an incorrect commit message, or minor changes without creating an entirely new commit. + +Using the amend feature is helpful for keeping a project's commit history clean and concise. + +## Syntax + +The basic syntax for the amend feature is: + +```shell +git commit --amend +``` + +To amend both the content of the commit and the commit message, the following would be used: + +```shell +git commit --amend -m "Your new commit message" +``` + +## Examples + +### Scenario: + +The developer created and committed a feature, but forgot to include a file: + +```shell +# Original commit +echo "Initial code" > feature.txt +echo "Forgotten content" > forgotten-file.txt +git add feature.txt # Dev forgot to add forgotten-file.txt +git commit -m "Add initial code for the feature" +``` + +Original commit history: + +```shell +git log --oneline +abc1234 Add initial code for the feature +``` + +The developer realized that they forgot a file in the original commit: + +```shell +# Amending the original commit +git add forgotten-file.txt +git commit --amend -m "Add initial code for the feature and forgotten file" +``` + +Amended commit history: + +```shell +git log --oneline +def5678 Add initial code for the feature and forgotten file # Commit abc1234 has been replaced by def5678 +``` + +### Example: + +To amend only the commit message: + +Original commit history: + +```shell +git log --oneline +abc1234 Original commit message +``` + +The commit message is edited: + +```shell +git commit --amend -m "Corrected commit message" +``` + +Amended commit history: + +```shell +git log --oneline +abc1234 Corrected commit message +``` + +> **Note**: Use `git commit --amend` carefully if the commit has already been shared with others, as it rewrites history. From 0efdfb9c95a4a4ef86d99258c08980a544d5c0db Mon Sep 17 00:00:00 2001 From: Dani Tellini Date: Tue, 17 Dec 2024 21:50:46 +0000 Subject: [PATCH 3/6] check fail fix --- content/git/concepts/amend/amend.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/git/concepts/amend/amend.md b/content/git/concepts/amend/amend.md index 9dca5ab5970..43149e1219b 100644 --- a/content/git/concepts/amend/amend.md +++ b/content/git/concepts/amend/amend.md @@ -35,7 +35,7 @@ git commit --amend -m "Your new commit message" ## Examples -### Scenario: +### Scenario The developer created and committed a feature, but forgot to include a file: @@ -69,7 +69,7 @@ git log --oneline def5678 Add initial code for the feature and forgotten file # Commit abc1234 has been replaced by def5678 ``` -### Example: +### Example To amend only the commit message: From 488b0c02f27cb6820bdba3b6ba78eda252447110 Mon Sep 17 00:00:00 2001 From: Sriparno Roy <89148144+Sriparno08@users.noreply.github.com> Date: Tue, 24 Dec 2024 18:50:11 +0530 Subject: [PATCH 4/6] Update amend.md --- content/git/concepts/amend/amend.md | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/content/git/concepts/amend/amend.md b/content/git/concepts/amend/amend.md index 43149e1219b..61648cc9126 100644 --- a/content/git/concepts/amend/amend.md +++ b/content/git/concepts/amend/amend.md @@ -9,7 +9,6 @@ Tags: - 'Documentation' - 'Error Handling' - 'Git' - - 'Version Control' CatalogContent: - 'learn-git' - 'paths/computer-science' @@ -23,21 +22,19 @@ Using the amend feature is helpful for keeping a project's commit history clean The basic syntax for the amend feature is: -```shell +```pseudo git commit --amend ``` To amend both the content of the commit and the commit message, the following would be used: -```shell +```pseudo git commit --amend -m "Your new commit message" ``` -## Examples +## Example 1 -### Scenario - -The developer created and committed a feature, but forgot to include a file: +Suppose, the developer created and committed a feature, but forgot to include a file: ```shell # Original commit @@ -47,14 +44,14 @@ git add feature.txt # Dev forgot to add forgotten-file.txt git commit -m "Add initial code for the feature" ``` -Original commit history: +Here's the original commit history: ```shell git log --oneline abc1234 Add initial code for the feature ``` -The developer realized that they forgot a file in the original commit: +The developer realized that he hasn't included a file in the original commit. So, he performs the amend operation to both include the file in that commit and change the commit message: ```shell # Amending the original commit @@ -62,35 +59,33 @@ git add forgotten-file.txt git commit --amend -m "Add initial code for the feature and forgotten file" ``` -Amended commit history: +Here's the amended commit history: ```shell git log --oneline def5678 Add initial code for the feature and forgotten file # Commit abc1234 has been replaced by def5678 ``` -### Example - -To amend only the commit message: +## Example 2 -Original commit history: +Suppose, the developer is going through another commit history: ```shell git log --oneline abc1234 Original commit message ``` -The commit message is edited: +While going through it, the developer didn't like the above commit message. So, he decides to use the amend operation to only change the commit message without touching the contents of the commit: ```shell git commit --amend -m "Corrected commit message" ``` -Amended commit history: +Here's the amended commit history: ```shell git log --oneline abc1234 Corrected commit message ``` -> **Note**: Use `git commit --amend` carefully if the commit has already been shared with others, as it rewrites history. +> **Note:** Use `git commit --amend` carefully if the commit has already been shared with others, as it rewrites history. From d44407022aa2ccbeeefa9e0b5dfc68b9048de472 Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Thu, 2 Jan 2025 22:13:42 +0530 Subject: [PATCH 5/6] Update amend.md minor fixes --- content/git/concepts/amend/amend.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/git/concepts/amend/amend.md b/content/git/concepts/amend/amend.md index 61648cc9126..f9ed2625202 100644 --- a/content/git/concepts/amend/amend.md +++ b/content/git/concepts/amend/amend.md @@ -14,13 +14,13 @@ CatalogContent: - 'paths/computer-science' --- -**Amend** is a Git feature that modifies the most recent commit. It allows developers to correct mistakes such as a missing file, an incorrect commit message, or minor changes without creating an entirely new commit. +**Amend** iis a Git feature that allows developers to modify the most recent commit. It is commonly used to correct mistakes such as adding a missing file, fixing an incorrect commit message, or making minor adjustments without creating an entirely new commit. -Using the amend feature is helpful for keeping a project's commit history clean and concise. +This feature is particularly helpful for maintaining a clean and concise commit history, ensuring that changes are logically grouped and easy to understand. ## Syntax -The basic syntax for the amend feature is: +The syntax for using the amend feature in Git is: ```pseudo git commit --amend From 0d2ac6d1afc94b05e7d6858d21f20c4aabce0967 Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Thu, 2 Jan 2025 22:14:07 +0530 Subject: [PATCH 6/6] Update amend.md --- content/git/concepts/amend/amend.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/git/concepts/amend/amend.md b/content/git/concepts/amend/amend.md index f9ed2625202..95b45f397b0 100644 --- a/content/git/concepts/amend/amend.md +++ b/content/git/concepts/amend/amend.md @@ -14,7 +14,7 @@ CatalogContent: - 'paths/computer-science' --- -**Amend** iis a Git feature that allows developers to modify the most recent commit. It is commonly used to correct mistakes such as adding a missing file, fixing an incorrect commit message, or making minor adjustments without creating an entirely new commit. +**Amend** is a Git feature that allows developers to modify the most recent commit. It is commonly used to correct mistakes such as adding a missing file, fixing an incorrect commit message, or making minor adjustments without creating an entirely new commit. This feature is particularly helpful for maintaining a clean and concise commit history, ensuring that changes are logically grouped and easy to understand.