Git. Things you should master about.
Git is a version control system for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily for source code management in software development, but it can be used to keep track of changes in any set of files.
Here are some note for basic Git commands I learned from online tutorial.
Git Reset vs Revert vs Checkout reference
Merge Conflict
Of course when team members work on a same project, there will possibly be some problems when pushing local branches. If team members work on separate file, then git could easily merged the branches to master automatically. But if they edit the same file in same lines, we are going to get conflict. What if there’s merge conflict when we commit our branches to master branch and how we can solve this issue?
Git merge — abort
If you decide to quit this merge or this situation, we can still revert the merge, this commands rebase the merge and we can go back where we were before merge.
If you decide to move forward merging, you can resolve it with following changes.
Accept Current Change
Accept Incoming Changes
Accept Both Changes
If we’re happy with this changes and start to merge again, we need to add the file and commit again.
git add <fileName>
git commit -m “merge <FileName”>
and you can check it with git log
We know it can be frustrating and having conflict when you work in code but only practice makes you perfect so don’t be afraid or freaked out when this kind of situation happening.
Modifying Commits
Git Conventional types
Sometimes it’s better to understand your commit messages easier if you add conventional types in your commit message.
Available types are:
- feat → Changes about addition or removal of a feature. Ex:
feat: add table on landing page
,feat: remove table from landing page
- fix → Bug fixing, followed by the bug. Ex:
fix: illustration overflows in mobile view
- docs → Update documentation (README.md)
- style → Updating style, and not changing any logic in the code (reorder imports, fix whitespace, remove comments)
- chore → Installing new dependencies, or bumping deps
- refactor → Changes in code, same output, but different approach
- ci → Update github workflows, husky
- test → Update testing suite, cypress files
- revert → when reverting commits
- perf → Fixing something regarding performance (deriving state, using memo, callback)
- vercel → Blank commit to trigger vercel deployment. Ex:
vercel: trigger deployment
And Here are useful Links to learn more about Git:
https://www.atlassian.com/git/tutorials/advanced-overview
Git Cheat Sheet : https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet