Skip to content

Commit

Permalink
Merge pull request #1081 from mi6/1330-git
Browse files Browse the repository at this point in the history
docs(root): added amending a commit guidance
  • Loading branch information
MI6-255 authored Aug 13, 2024
2 parents 3302940 + c6e24b0 commit 943d32d
Show file tree
Hide file tree
Showing 2 changed files with 461 additions and 423 deletions.
38 changes: 38 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Welcome and thank you for contributing to the [Intelligence Community Design Sys
- [Accessibility](#accessibility)
- [Style guide](#style-guide)
- [Git commit](#git-commit)
- [Amending a commit](#amending-a-commit)
- [Styling](#styling)

- [Testing](#testing)
Expand Down Expand Up @@ -153,6 +154,43 @@ Follow these steps when making a commit:
8. Provide a link to the issue by entering the reference e.g. `#123`.
9. When the editor opens up, check your commit message and press `Ctrl`+`x` to confirm.

### Amending a commit

If you need to make changes to a commit (for example, after receiving comments on a PR), follow these steps:

1. **If you're amending the most recent commit:**
- Stage your changes using `git add` and include the files you want to update.
- Run `git commit --amend --no-edit` to amend the most recent commit without changing the commit message.
- The Commitizen prompt will still appear as if you are making a new commit. Exit the prompt (usually by pressing Ctrl+C).
- Push the changes to the remote repository using: `git push --force`.

2. **If you're amending an older commit:**
- Use `git rebase` to modify an older commit. For example, to modify commit `a1312407`, run:
```sh
git rebase --interactive a1312407
```

- In the default editor, change `pick` to `edit` for the line mentioning `a1312407`.

- Save the file and exit. Git will interpret and automatically execute the commands in the file, placing you in the state just after creating commit `a1312407`.

- Amend the commit by making your changes and then running:
```sh
git commit --all --amend --no-edit
```

- The Commitizen prompt will still appear as if you are making a new commit. Exit the prompt (usually by pressing Ctrl+C).

- Continue the rebase process by running:
```sh
git rebase --continue
```

- Push the changes to the remote repository using:
```sh
git push --force
```

### Styling

- Avoid using inline css.
Expand Down
Loading

0 comments on commit 943d32d

Please sign in to comment.