From 38a99c449bdabeffc9ab9efbb728ba981b5c9af4 Mon Sep 17 00:00:00 2001 From: Ric Harvey Date: Fri, 3 May 2024 17:19:31 +0100 Subject: [PATCH] add first bit of merging doc --- branches.md | 14 ++++++++++++++ merging.md | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/branches.md b/branches.md index dec5580..d14bc65 100644 --- a/branches.md +++ b/branches.md @@ -65,6 +65,20 @@ git push --set-upstream origin issuse99 Now git will push the code to the remote repository and will also know what to do next time you run ```git push``` +Our git tree now looks something like this: + +```mermaid +gitGraph + commit + commit + branch issue99 + checkout issue99 + commit + checkout main + commit + commit +``` + ## Switching branches in the CLI - Open the terminal diff --git a/merging.md b/merging.md index 19b362c..84f1c5a 100644 --- a/merging.md +++ b/merging.md @@ -1,5 +1,50 @@ -## Merging +# Bringing code back together +## Merge Requests in Gitlab + +## Merging via the CLI +Lets take our example of making a branch for **issue 99**, the diagram below shows the current state of the git repository. + +```mermaid +gitGraph + commit + commit + branch issue99 + checkout issue99 + commit + checkout main + commit + commit +``` + +Merging this is pretty simple, you can do it with the following instructions. + +```bash +# Switch back to the main branch +git checkout main + +# Merge the branches +git merge issue99 + +# Push the changes to the remote repository +git push +``` + +The diagram below shows what happened to our repository and how it got merged or flattened back into the **main** branch. + +```mermaid +gitGraph + commit + commit + branch issue99 + checkout issue99 + commit + checkout main + commit + commit + merge issue99 + commit +``` --- ##### Follow me for more guides