JavaScript
TypeScript
NodeJS

Git - Commands Used from Receiving a Task to Creating a PR ๐ŸŽ‰

Pin Nguyen

Pin Nguyen

Software Developer

July 29, 2024

3 min read

Git - Commands Used from Receiving a Task to Creating a PR ๐ŸŽ‰

Git offers many commands, but which ones are most commonly used in real-world projects? ๐Ÿค” As an essential tool for version control, Git helps track changes, collaborate with teams, and maintain code stability. Mastering key commands boosts productivity, reduces conflicts, and keeps the codebase clean. Letโ€™s dive into these frequently used commands! ๐Ÿ˜‰

Agenda

0. Receiving a Task, for example, task ID 123

  • Later, when you see a branch created with the number 123, you can assume it's the taskId.
  • For example, in my team, we develop on the develop branch.

1. Get the latest code from the develop branch

git checkout develop # switch to the develop branch

git pull # lfetch the latest code

2. Work on the task directly on the develop branch

CODING CHANGES ๐Ÿ˜Ž
After finishing your code, review your changes carefully and slowly.
Review the coding conventions.
Check if all console logs are removed.
Verify if there are any redundant imports.
Check for eslint issues.
If thereโ€™s complex logic, add comments.
If thereโ€™s too much if/else logic, refactor it.
...
Review your code in VSCode for better readability. If you want to look cool, use git diff and check instead! ๐Ÿ˜Ž
Make it a habit to review your code thoroughly before handing it to your lead for review! ๐Ÿ˜‰

3. Prepare to create a Pull Request (PR)

After finishing your code, itโ€™s time to prepare a PR.
However, while you were working, someone else might have updated the develop branch.
NSo, you must fetch the latest code from the develop branch before applying your changes.

git add . # stage all changes

git stash  # save all code changes to stash (temporary storage)

git pull  # fetch the latest code

4. Create a branch for your code changes

git checkout -b feature/123-add-address-ui

5. Retrieve your stashed code (saved earlier using git stash)

git stash pop

OPTIONAL: Resolve conflicts if there are any. Remember to test again to ensure the code still works smoothly. ๐Ÿ˜…

6. Create a commit and write a commit message

git status # view the changed files
git add . # stage all changes

git commit -m "[123] Add address UI

- More details about your PR
- Keep it short and descriptive"

๐Ÿ“Note the yellow text:
- The first line is the title.
- The second line is empty (MANDATORY).
- From the third line onward, provide additional details about your Pull Request.
This convention helps automatically populate the title and description fields in GitHub, GitLab, Bitbucket, etc.

7. Push code to the remote repository (GitHub, GitLab, Bitbucket, etc.)

git push -u origin feature/123-address-ui

Finally, create a PR/MR into the develop branch on the remote repository and request a lead review. Done! Hehe ๐Ÿ˜„

๐Ÿ“NOTES

  • Each project may have different branch naming conventions; follow your teamโ€™s rules.
  • The branch you work on also depends on the team; itโ€™s not always develop.
  • Not everyone follows the same process as mine; everyone has their own style.
  • The process shared above is something Iโ€™ve applied during my career and found effective. Iโ€™m sharing it here for your reference; feel free to adapt it if you find it helpful. ๐Ÿ˜Š

WISH YOU ALL GOOD HEALTH AND SUCCESSFUL LEARNING! โค๏ธ

Pin Nguyen

Pin Nguyen

July 29, 2024
3 min read

Back to Blog

pin nguyen cute

Full-stack engineer building data platforms and big-data systems โ€” from real-time pipelines and scalable APIs to polished user interfaces.

Available for work

Connect

nguyenthanhpin95@gmail.com

ยฉ 2026 Pin Nguyen. Built with Next.js & TypeScript.