From 82911deab7902c01ae04c4270b3ae75a9e3eee3f Mon Sep 17 00:00:00 2001 From: laurentheirendt <laurent.heirendt@uni.lu> Date: Mon, 23 Sep 2019 12:09:24 +0200 Subject: [PATCH] redo merge slide --- .../slides/merge.md | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/2019/2019-09-24_advancedGitTraining/slides/merge.md b/2019/2019-09-24_advancedGitTraining/slides/merge.md index 921ef8a5..c3e00b3f 100644 --- a/2019/2019-09-24_advancedGitTraining/slides/merge.md +++ b/2019/2019-09-24_advancedGitTraining/slides/merge.md @@ -1,41 +1,37 @@ -# Theory: Merging branches +# Merging branches locally +* Merge a branch into another one locally * Combines all the commits from a source branch onto a target branch +* In practice, this is very useful if you 'just want to try out something', or 'draft' something +# Example (1) -# Practical: Merging branches - -* Create a new branch from your own branch: +* Create a new branch from your `myBranch` branch: ```bash -$ git checkout -b Feature1 +$ git checkout myBranch +$ git checkout -b myNewBranch ``` -* Add two files to the Feature1 branch in two separate commits: -```bash -$ echo "Code that is merged into myBranch" > merge1.txt -$ git add merge1.txt -$ git commit -m "first commit to be merged" -``` +* Add two files to the `myNewBranch` branch in two separate commits: ```bash -$ echo "Code that is merged into myBranch" > merge2.txt -$ git add merge2.txt -$ git commit -m "second commit to be merged" +$ echo "# Trevor Westman" > trevor.md +$ # add and commit the file trevor.md +$ echo "# Gustav Bergen" > gustav.md +$ # add and commit the file gustav.md ``` +# Example (2) - -# Practical: Merging branches - -* Check the commit log of the myBranch and Feature1 branch +* Check the `log` of the `myNewBranch` and `myBranch` branches: ```bash -$ git log +$ git log myBranch +$ git log myNewBranch ``` -* Go to myBranch and merge the Feature1 branch into it +* Go to `myBranch` and merge the `myNewBranch` branch into it ```bash -$ git merge Feature1 +$ git checkout myBranch +$ git merge myNewBranch +$ git log myBranch ``` - -* This will move all changes made in the Feature1 branch -onto myBranch, effectively fusing the two together. \ No newline at end of file -- GitLab