From 336f067c521488c316c6ef0edb9edc367d2289b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20LUDWIG?= Date: Fri, 16 Jun 2023 22:36:20 +0200 Subject: [PATCH] fix(posts): add explanations for Git (cherry-pick + merge squash) --- posts/git-ultimate-guide.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/posts/git-ultimate-guide.md b/posts/git-ultimate-guide.md index dfa247a..5858dc5 100644 --- a/posts/git-ultimate-guide.md +++ b/posts/git-ultimate-guide.md @@ -21,7 +21,7 @@ Git was originally authored by [Linus Torvalds](https://en.wikipedia.org/wiki/Li Git allows: -- to be able to work with several people on the same codebase. +- to work with several people on the same codebase. - track changes to know who did what and when. - revert changes. @@ -122,6 +122,13 @@ git checkout # Merge a branch into the current branch git merge +# Combine multiple commits of a branch into one for a merge +git merge --squash + +# Change several past commits (interactive rebase) +# HEAD points to the current consulted commit. +git rebase --interactive HEAD~ + # Delete a branch git branch --delete git push --delete @@ -132,14 +139,11 @@ git fetch --prune # Revert a commit git revert -# Change several past commits (interactive rebase) -# HEAD points to the current consulted commit. -git rebase --interactive HEAD~ - # Reset the current branch, delete all commits since (without removing the changes) git reset --soft # Apply the changes introduced by some existing commits +# (by first being on the branch where you want to apply the commit) git cherry-pick ```