From 8c9fd06e839c06717dd2dcb067371a5e1fc71801 Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Tue, 23 Jan 2024 00:59:38 +0100 Subject: git: add merge commands --- src/tools/git.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/tools') diff --git a/src/tools/git.md b/src/tools/git.md index eb1f633..a1f4614 100644 --- a/src/tools/git.md +++ b/src/tools/git.md @@ -75,6 +75,22 @@ git push origin --tags .... push local tags to origin (or other remote) ``` +## Merging +```markdown + git merge [opt] .... integrate changes from since + opt: current branch and diverged + --squash ................ merge all commits into a single one + --no-commit ............. dont generate commit if the merge succeeds + + git merge-base + get the common ancestor, since both commits diverged + + git rebase -i .... interactively rebase on , also supports actions + like squashing, editing, rewording, etc of commits + + git cherry-pick .... apply commit on current branch +``` + ## Worktree Worktrees allow to maintain multiple working trees in the filesystem linked to the same repository (shared .git folder). @@ -130,7 +146,9 @@ the same repository (shared .git folder). git apply --stat ... see which files the patch would change git apply --check .. see if the patch can be applied cleanly - git apply .......... apply the patch locally without creating a commit + git apply [-3] ..... apply the patch locally without creating a commit, + if the patch does not cleanly apply -3 allows for + a 3-way merge # eg: generate patches for each commit from initial commit on git format-patch -N $(git rev-list --max-parents=0 HEAD) -- cgit v1.2.3