From 6a3f335f9f5cf4eca9829d324c39111118995337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20LUDWIG?= Date: Fri, 28 Jul 2023 11:40:19 +0200 Subject: [PATCH] fix(posts): update git blog post --- posts/git-ultimate-guide.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/posts/git-ultimate-guide.md b/posts/git-ultimate-guide.md index 5858dc5..4680dc1 100644 --- a/posts/git-ultimate-guide.md +++ b/posts/git-ultimate-guide.md @@ -122,6 +122,11 @@ git checkout # Merge a branch into the current branch git merge +# Note: Merge creates a "Merge commit" when the base branch and the branch to merge have diverged (they have different commits). + +# To avoid creating a "Merge commit", we can use rebase instead of merge. +git rebase --interactive + # Combine multiple commits of a branch into one for a merge git merge --squash @@ -145,6 +150,13 @@ 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 + +# To list all commits that differ between two branches +git log .. # commits in branch2 that are not in branch1 (branch2 ahead of branch1, branch2 behind branch1) +git log .. # commits in branch1 that are not in branch2 (branch1 ahead of branch2, branch1 behind branch2) + +# Summary of commit authors across all branches, excluding merge commits. +git shortlog --summary --numbered --all --no-merges ``` ## `.gitignore` file @@ -194,7 +206,7 @@ As we have seen in the [Get started with `git` and `.gitconfig` config file](#ge That means that **anyone can create a commit with any name and email address and claim to be whoever they want** when they create a commit. -To avoid this, you can sign your commits with a [GPG](https://gnupg.org/) key. +To avoid this, you can sign your commits with a [GNU Privacy Guard](https://gnupg.org/) (gpg) key. You can find more information about signing commits in the [official documentation](https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work).