Alice: merging without conflicts
Alice knows that branches must be integrated often to avoid problems, so she will merge the vocabulary branch with the main one.
Lab
- First, she checks that she is in the
main
branch
git branch
- Now, she checks the differences between both branches
git diff main vocabulary-chapter-01
- There are some long lines, so maybe it would be better to get the difference without using
delta
. To deactivate it, Alice just pipes the output ofgit
to another command
git diff main vocabulary-chapter-01 | cat - # diff without using delta
- This is the moment to create a new
commit
with the content of both versions merged
git merge vocabulary-chapter-01 -m "Merged vocabulary"
- Now the main branch contains all the words, plus the stranger’s profession:
cat chapter-01.md \
| grep -e sand -e shore -e beach -e "lighthouse keeper" -C 9999 --color
- The log of the main branch will include the changes performed on the merged one:
git log
- As time passes and we keep adding commits to the history, it is more and more convenient to simplify the output of the log
git log --oneline
* And once we start to merging different branches, it is always nice to be able
to see the different timelines of our project visually:git log --oneline --gr███
git log --oneline --gr███
Solution
git log --oneline --graph