4 Git Habits & curated list of life-saving articles
Tags: github, beginners, devjournal, productivity
Published: 2021-06-05 13:14:52

Hi folks.
In this post I want to share some tips and suggestions on common best practices for the method of work, that are not always explicitly stated/taught.</br>
When we transition to a new environment, there's a certain learning curve involved before we get on with our work smoothly.
I struggled with my modus operandi and after tripping on many pitfalls, I think these tips might be of help:</br>

1. **Don't branch when you start working. Branch when need to push.**</br>
I've had situations where I faced merge conflicts due to early branching. You don't know how long its gonna take for you to fix that defect or complete that story. By the time you are ready to push the changes to remote repository, there might be significant changes in many files. And may be even on the one that you're working on. This is typically the case when many teams are working on a repository. Hence, always create a branch to push your code when you are actually ready to push.

2. **Pull every morning.** Keep the code base up to date</br>
Branching off of the previous comment, keeping the code base up to date is ofcourse very essential, but the frequency is what matters. I had this question when I started in my new role *"how often should I pull?"*</br>
The answer is every morning. Don't worry you won't lose your work. And if you're unable to, because of un-committed changes, then stash your things are apply them after you've pulled.
This way, you can lift-off from where you ended yesterday.

3. **Always sign/author your commits**, if you don't.</br>
Although some organizations have some guidelines regarding this,  but that might not always be the case. Even though the organization has a way to keep track of who's changed what, it's always advisable to author your commits.
I prefer ending the commit message with:
`Reviewed by: Reviewer Name <email@addre.ss>`
`Signed-off-by: Your Name <your@email.id>`

4. **Squash all your commits into one once you're done.**</br>
This is something you must be aware of already. Squash all your commits before merging. This way all the code changes for a fix/feature are consolidated into one, and the whole thing is much clearly maintained and tracked.

These are the few things I learned the hard way. I hope you adopt these habits soon if you don't already.</br>
Before signing-off, below are some guides and articles in **Bonus** section, that I find very useful & you might too.</br></br>
&nbsp;&nbsp;***And even though cats may rule this world one day, you are reading Code with P.*** 👋🐈

#### BONUS - Resources

- [Git Crash Course](https://github.com/eclipse/omr/blob/master/doc/GitCrashCourse.md) by eclipse/omr project at [github.com](https://github.com/eclipse/omr)
- [What is Git Stash, how to use Git Stash?](https://yuvaraj.hashnode.dev/learn-the-hidden-feature-in-git-stash) by @[Yuvaraj](https://hashnode.com/@yuvgeek)
- [Top 10 Git Commands Every Developer Should Know](https://muthuannamalai.hashnode.dev/top-10-git-commands-every-developer-should-know) By @[Muthu Annamalai Venkatachalam](https://hashnode.com/@muthuannamalai12)
- [Confusing Terms in the Git Terminology](https://pragativerma18.hashnode.dev/confusing-terms-in-the-git-terminology) by @[Pragati Verma](https://hashnode.com/@PragatiVerma18)
-  [Most practical git commands in a real workflow](https://jinggu.hashnode.dev/most-practical-git-commands-in-a-real-workflow)  by @[Jing Gu](https://hashnode.com/@JinG)
- [What is Commit Signing in Git](https://www.freecodecamp.org/news/what-is-commit-signing-in-git/) by [Seth Falco](https://twitter.com/SethFalco)