From b1e58cfb058d445075b992c8c57bf3ec477499c9 Mon Sep 17 00:00:00 2001 From: Midori <50433979+natsuk4ze@users.noreply.github.com> Date: Sat, 10 Jun 2023 23:38:36 +0900 Subject: [PATCH 1/6] Update FAQ.md --- docs/HowToGuides/FAQ.md | 43 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/docs/HowToGuides/FAQ.md b/docs/HowToGuides/FAQ.md index e9dce12deca53..bdacf78b374bb 100644 --- a/docs/HowToGuides/FAQ.md +++ b/docs/HowToGuides/FAQ.md @@ -133,5 +133,44 @@ git rebase --continue ### How do I clean up my git history? -TODO: Link to a beginner-friendly external resource, or (less preferably) -describe basic usage of rebase here. +Git's history can sometimes become cluttered with many small commits. +Fortunately, Git has a feature called `rebase` that allows you to clean up your commit history. +Here's a simple way to use it, If you want to learn more, +[GitHub - About Git rebase](https://docs.github.com/en/get-started/using-git/about-git-rebase) +provides a comprehensive overview of `rebase`: + +1. Begin an interactive rebase: Use `git rebase -i HEAD~N`, where `N` is the number of commits + from the latest one you want to edit. This will open a text editor, + listing the last `N` commits with the word "pick" next to each one. + + ```sh + git rebase -i HEAD~N + ``` + +2. Edit the commits: Replace "pick" with the operation you want to perform on the commit: + + - `reword`: Change the commit message. + - `edit`: Amend the commit. + - `squash`: Combine the commit with the previous one. + - `fixup`: Similar to `squash`, but discard this commit's log message. + - `drop`: Remove the commit. + +3. Save and exit: After saving and closing the file, git will execute each operation. + If you selected `reword`, `edit`, or `squash`, git will pause and give you a chance + to alter the commit message or the commit itself. + + ```sh + git commit --amend + ``` + +4. Continue the rebase: Once you're done with each commit, you can continue the rebase + using `git rebase --continue`. If you want to abort the rebase at any point, + you can use `git rebase --abort`. + + ```sh + git rebase --continue + ``` + +It's important to note that you should only rebase commits that have not been pushed to a public branch. +If you need to tidy up commits that have already been pushed, +it's generally better to use git revert to avoid causing confusion for other developers. From b46943f222d8ee82a3e133dd79278e62e54c3714 Mon Sep 17 00:00:00 2001 From: Midori <50433979+natsuk4ze@users.noreply.github.com> Date: Sun, 11 Jun 2023 00:11:31 +0900 Subject: [PATCH 2/6] Add syntax --- docs/HowToGuides/FAQ.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/HowToGuides/FAQ.md b/docs/HowToGuides/FAQ.md index bdacf78b374bb..8d65c67f27271 100644 --- a/docs/HowToGuides/FAQ.md +++ b/docs/HowToGuides/FAQ.md @@ -173,4 +173,4 @@ provides a comprehensive overview of `rebase`: It's important to note that you should only rebase commits that have not been pushed to a public branch. If you need to tidy up commits that have already been pushed, -it's generally better to use git revert to avoid causing confusion for other developers. +it's generally better to use `git revert` to avoid causing confusion for other developers. From a446df35bad4c1633afcee709978da3405d3e482 Mon Sep 17 00:00:00 2001 From: Midori <50433979+natsuk4ze@users.noreply.github.com> Date: Tue, 13 Jun 2023 00:28:56 +0900 Subject: [PATCH 3/6] Update docs/HowToGuides/FAQ.md Co-authored-by: Luciano Almeida --- docs/HowToGuides/FAQ.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/HowToGuides/FAQ.md b/docs/HowToGuides/FAQ.md index 8d65c67f27271..b93205caefc61 100644 --- a/docs/HowToGuides/FAQ.md +++ b/docs/HowToGuides/FAQ.md @@ -135,9 +135,10 @@ git rebase --continue Git's history can sometimes become cluttered with many small commits. Fortunately, Git has a feature called `rebase` that allows you to clean up your commit history. -Here's a simple way to use it, If you want to learn more, +If you want to learn more, [GitHub - About Git rebase](https://docs.github.com/en/get-started/using-git/about-git-rebase) -provides a comprehensive overview of `rebase`: +provides a comprehensive overview of `rebase`. +Here's a small gist that goes through the basics on how to use it: 1. Begin an interactive rebase: Use `git rebase -i HEAD~N`, where `N` is the number of commits from the latest one you want to edit. This will open a text editor, From ff50ccacc8a036dfcc7b8c30220660e0d9ef953a Mon Sep 17 00:00:00 2001 From: Midori <50433979+natsuk4ze@users.noreply.github.com> Date: Tue, 13 Jun 2023 11:59:44 +0900 Subject: [PATCH 4/6] Update FAQ.md Make the text more recommended. --- docs/HowToGuides/FAQ.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/HowToGuides/FAQ.md b/docs/HowToGuides/FAQ.md index b93205caefc61..e5d51b916e255 100644 --- a/docs/HowToGuides/FAQ.md +++ b/docs/HowToGuides/FAQ.md @@ -172,6 +172,6 @@ Here's a small gist that goes through the basics on how to use it: git rebase --continue ``` -It's important to note that you should only rebase commits that have not been pushed to a public branch. +We suggest considering to rebase only those commits that haven't been pushed to a public branch. If you need to tidy up commits that have already been pushed, it's generally better to use `git revert` to avoid causing confusion for other developers. From 7b2c3d22527795adeb115c916c6dd0f7d13c5e88 Mon Sep 17 00:00:00 2001 From: Midori <50433979+natsuk4ze@users.noreply.github.com> Date: Tue, 13 Jun 2023 12:03:21 +0900 Subject: [PATCH 5/6] Add syntax in FAQ.md --- docs/HowToGuides/FAQ.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/HowToGuides/FAQ.md b/docs/HowToGuides/FAQ.md index e5d51b916e255..de106d06addf7 100644 --- a/docs/HowToGuides/FAQ.md +++ b/docs/HowToGuides/FAQ.md @@ -172,6 +172,6 @@ Here's a small gist that goes through the basics on how to use it: git rebase --continue ``` -We suggest considering to rebase only those commits that haven't been pushed to a public branch. +We suggest considering to `rebase` only those commits that haven't been pushed to a public branch. If you need to tidy up commits that have already been pushed, it's generally better to use `git revert` to avoid causing confusion for other developers. From 01da1cbc572795c78694847993a2fe6a2310f406 Mon Sep 17 00:00:00 2001 From: Midori <50433979+natsuk4ze@users.noreply.github.com> Date: Wed, 14 Jun 2023 11:00:55 +0900 Subject: [PATCH 6/6] Add warnings on top --- docs/HowToGuides/FAQ.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/HowToGuides/FAQ.md b/docs/HowToGuides/FAQ.md index de106d06addf7..4670a199470b2 100644 --- a/docs/HowToGuides/FAQ.md +++ b/docs/HowToGuides/FAQ.md @@ -138,6 +138,14 @@ Fortunately, Git has a feature called `rebase` that allows you to clean up your If you want to learn more, [GitHub - About Git rebase](https://docs.github.com/en/get-started/using-git/about-git-rebase) provides a comprehensive overview of `rebase`. + +> **Warning** +We suggest considering to `rebase` only those commits that haven't been pushed to a public branch. +Rebasing existing commits would block merging because we don't allow force pushes to the repository. +If you need to tidy up commits that have already been pushed, +it's generally better to use `git revert` for the sake of avoid causing confusion for other developers. + + Here's a small gist that goes through the basics on how to use it: 1. Begin an interactive rebase: Use `git rebase -i HEAD~N`, where `N` is the number of commits @@ -171,7 +179,3 @@ Here's a small gist that goes through the basics on how to use it: ```sh git rebase --continue ``` - -We suggest considering to `rebase` only those commits that haven't been pushed to a public branch. -If you need to tidy up commits that have already been pushed, -it's generally better to use `git revert` to avoid causing confusion for other developers.