This week, I practiced using git to manage multiple changes in one project at the same time and using git merge, so I'll introduce these in my steps.
Add new features and the example
Last week my partner made changes to my SSG and I merged it.
This time, I implemented the following two features by myself.
1. Add an optional -l, --lang which indicates the language to use when generating the lang attribute on the root element
Type: $node pajama-ssg -i test.txt -l ja
on the command line
Generates:<html lang="ja">
tag
2. Add support for a horizontal rule in Markdown
Add: 3 hyphens (---) in the .md file (e.g. test.md)
Type: node pajama-ssg -i test.md
on the command line
Generates:<hr />
tag
Create Branches
First, I created 2 new topic branches for the updates. The first one was #issue-17 and the second one was #issue-18.
Second, I checked if I was on my main branch with $ git checkout
.
When I worked on the new branch and for switching to it, I used $git checkout -b issue-17
(issue-18) git command.
After I implemented the feature and tested, I checked which files are not staged and which are untracked with $git status
command again. Then, I added the updated file and committed the changes with $git add .\pajama-ssg.js
and $ git commit -m "add language feature"
.
Time to Merge!
I implemented new features and committed for both issues. I merged them with $git merge issue-17
command.
It was successful with these results, so I double checked with $git log
if it was merged properly.
PS C:\Users\Mizuho\desktop\OSD600\pajama-ssg> git merge issue-17
Updating 3f1d71d..45e4957
Fast-forward
pajama-ssg.js | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
PS C:\Users\Mizuho\desktop\OSD600\pajama-ssg> git log
Author: MizuhoOkimoto <54873998+MizuhoOkimoto@users.noreply.github.com>
Date: Thu Sep 30 17:12:16 2021 -0400
add language feature
commit 3f1d71dc07547f8fcacba9d3f4d3dd9bf2b3d926 (origin/main, origin/HEAD)
Merge: e7e77b0 e725a62
Author: MizuhoOkimoto <54873998+MizuhoOkimoto@users.noreply.github.com>
Date: Fri Sep 24 13:53:08 2021 -0400
Merge branch 'issue-5' into main
Push my main branch to GitHub
I merged both updates, so I switched to my main branch and I pushed merges and tested main branch to GitHub.
PS C:\Users\Mizuho\desktop\OSD600\pajama-ssg> git push origin
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 8 threads
Compressing objects: 100% (9/9), done.
Writing objects: 100% (9/9), 1.11 KiB | 567.00 KiB/s, done.
Total 9 (delta 7), reused 0 (delta 0)
remote: Resolving deltas: 100% (7/7), completed with 2 local objects.
To https://github.com/MizuhoOkimoto/pajama-ssg.git
3f1d71d..9f8b2dc main -> main
Close Issue-#17 and Issue-#18
Finally, I closed both issues on my GitHub repository. When I closed them I posted comments with Closed by 45e4957
(issue-#18 is Closed by 9f8b2dc
). By mentioning these numbers, I was able to see which code the file was merged with by clicking on the number.
Conclusion
Through this lab I learned how to work in parallel branches of a project by actually working on it. I felt it was very important knowledge when contributing to open source in the future or when working on projects with multiple people.
Links
Project repository: https://github.com/MizuhoOkimoto/pajama-ssg
Issues URLs: issue-#17, issue-#17
Merge Commit URLs: 45e4957, 9f8b2dc
It's getting cold, I hope you're staying warm šš
Top comments (0)