Skip to content
Zain Fathoni edited this page Apr 23, 2019 · 3 revisions

Git Fundamentals

Since we are using GitHub as our main collaboration tool, it's mandatory for each of us to understand the fundamentals of Git. Please familiarize yourself with these Git operations and their fundamental concepts:

  • commit
  • branch
  • merge
  • rebase
  • reset
  • revert
  • clone
  • fork
  • bisect

If you don't know what those Git operations mean, just ping me in the group chat so I can help you explaining them.

Git Learning Resources

Here are a few free resources that might be useful to help you learning Git fundamentals:

Git Commits Signing

Since I have never met most of the collaborators prior to this project initiation, I want to make sure that all of them are accountable of the codes they contributed.

Therefore, I decided that it is mandatory for the Pull Requests to be merged to only contains commits with verified signatures. If you accidentally committed an unsigned commit, you can try to rewrite the Git commit history. Just reach out to me, I will be glad to help you if you get that kind of problem.

Git Commit Message Guideline

This guideline applies to all manual commits.

General rules

  1. Separate subject from body with a blank line
  2. Limit the subject line to 50 characters (exclude tags)
  3. Capitalize the subject line
  4. Do not end the subject line with a period
  5. Use the imperative mood in the subject line
  6. Wrap the body at 72 characters
  7. Use the body to explain what and why vs. how

In the event of special case, you will need to indicate in the title line and explain what are the potential impacts.

Special cases and tags:

  • Breaking changes - [Breaking]
  • New Features [New]
  • Bugfix [Fix]
  • Refactor - [Refactor]
  • Deprecation - [Deprecate]
  • Fix PR comment or code cleanup - [Clean]
  • Adding/updating tests - [Test]

Note: We should use merge commit to aggregate multiple commit messages. Commit message usually contains the ticket number in the branch name, so we do not require it in the commit message.

Good Commit Example

[Breaking][new] Use a more secure hashing algo for password :boom:

This may affect services that cache password hash for authentication.

Changelog Example

Changelog for 21st March 2019

[Refactor] Merging Tim’s spaghetti branch
Why?
It’s a frequently requested type of pasta
It makes the code more tasty

[Breaking] Changed the password hashing algo to bcrypt
As opposed to what we were using originally which was plaintext. The legal department forced us to rush this but jokes on them though! The DB is not password protected.

---

Changelog for 22nd March 2019
[Refactor] Refactoring PayPal payment gateway code to improve stability.

---

Changelog for 30th March 2019
[Deprecated] POST /shippers/:id/top-up/paypal is now deprecated
Because the previous engineer who wrote it, redirected the PayPal payment to his own account.

Further readings: https://chris.beams.io/posts/git-commit/ https://wiki.openstack.org/wiki/GitCommitMessages https://gitmoji.carloscuesta.me/

Git Force Push

I don't always push --force, but when I do, I use push --force-with-lease

-–force considered harmful; understanding git’s -–force-with-lease