Skip to content
Snippets Groups Projects
Verified Commit 82911dea authored by Laurent Heirendt's avatar Laurent Heirendt :airplane:
Browse files

redo merge slide

parent 31c46285
No related branches found
No related tags found
No related merge requests found
# 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 * 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 `myBranch` branch:
* Create a new branch from your own branch:
```bash ```bash
$ git checkout -b Feature1 $ git checkout myBranch
$ git checkout -b myNewBranch
``` ```
* Add two files to the Feature1 branch in two separate commits: * Add two files to the `myNewBranch` 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"
```
```bash ```bash
$ echo "Code that is merged into myBranch" > merge2.txt $ echo "# Trevor Westman" > trevor.md
$ git add merge2.txt $ # add and commit the file trevor.md
$ git commit -m "second commit to be merged" $ echo "# Gustav Bergen" > gustav.md
$ # add and commit the file gustav.md
``` ```
# Example (2)
* Check the `log` of the `myNewBranch` and `myBranch` branches:
# Practical: Merging branches
* Check the commit log of the myBranch and Feature1 branch
```bash ```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 ```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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment