Skip to content

Commit b2021ec

Browse files
committed
move command line git merge to 4.1
1 parent 82bca27 commit b2021ec

2 files changed

Lines changed: 21 additions & 24 deletions

File tree

episodes/41-code-review.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,27 @@ This tells the author you are happy for them to merge the pull request.
567567
![](fig/github-merge-pull-request.png){alt='Merging a pull request in GitHub' .image-with-shadow width="800px"}
568568
2. Delete the merged branch to reduce the clutter in the repository.
569569

570+
::: callout
571+
572+
### Merge via command line
573+
574+
The `git merge` command provides a way to directly merge branches on your local. In general, when adding changes to the `main` branch, this is not a good practice since it bypasses the code review process. It is a common practice for an open-source project to set its `main` branch protected, meaning pushing directly to `main` branch will fail. Therefore, even you can merge to `main` locally, you will not be able to push the changes to the remote repository.
575+
576+
On the other hand, the `git merge` command can be very useful for keeping your feature branch up to date with the `main` branch. For example, if you are working on a branch `my-feature` and the `main` branch has received new commits (e.g. someone else has merged their pull request), you can do the following to include changes from `main` into your feature branch:
577+
578+
```bash
579+
# First update your local main branch
580+
$ git checkout main
581+
$ git pull main
582+
# Then switch back to your feature branch and merge the latest main into it
583+
$ git checkout my-feature
584+
$ git merge main
585+
```
586+
587+
In this way, you can keep your feature branch up to date. You may need to resolve conflicts that arise during this process.
588+
589+
:::
590+
570591
## Writing Easy-To-Review Code
571592

572593
There are a few things you can do to make it

episodes/42-software-reuse.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -344,30 +344,6 @@ Ensure you prioritise and work on the most pressing issues first!
344344

345345
::::::::::::::::::::::::::::::::::::::::::::::::::
346346

347-
## Merging into `main`
348-
349-
Once you have done these updates,
350-
commit your changes,
351-
and if you are doing this work on a feature branch also ensure you merge it into `develop`,
352-
e.g.:
353-
354-
```bash
355-
$ git switch develop
356-
$ git merge my-feature-branch
357-
```
358-
359-
Finally, once we have fully tested our software
360-
and are confident it works as expected on `develop`,
361-
we can merge our `develop` branch into `main`:
362-
363-
```bash
364-
$ git switch main
365-
$ git merge develop
366-
$ git push origin main
367-
```
368-
369-
The software on your `main` branch is now ready for release.
370-
371347
## Tagging a Release in GitHub
372348

373349
There are many ways in which Git and GitHub can help us make a software release from our code.

0 commit comments

Comments
 (0)