Best Practices for Git Commits When Working on Projects

0
7
Asked By Cod3Crafter42 On

Hey everyone! I need some guidance on the right way to handle Git commits for projects I want to showcase on my resume. I usually work on both a desktop and a laptop, and when I'm just learning something in a private repo, I commit randomly whenever I'm switching machines without thinking much about it.

However, I'm more concerned about how to manage my commits for projects that I want to display.

1. If I'm in the middle of implementing a feature and have to leave, should I still commit even if things aren't working? What should I write in the commit message? I wouldn't normally commit if I were continuing on the same machine.

2. I'm also learning while I code, and I know I won't always get it right on the first try. If I commit code I know is incorrect but want to keep track for educational purposes, will that hurt my commit history? How should I approach this?

2 Answers

Answered By DevGuru11 On

To keep your commit history neat, it's best to work on a feature branch and only merge into the main branch once everything is complete. When you do merge, consider squashing your commits into one with a clear description. If you accidentally introduce a bug, you can easily revert or add a new commit to fix it; it's really not a big deal.

Answered By CodeNinja88 On

Using Pull Requests and squashing your commits can help maintain a clean commit history. But honestly, most employers probably won’t even look at your commit history in detail, so just do what feels right for you.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.