Working with Git like a Senior

Tram Ho

Commemoration

  • Git is simply understood as a version of source-code management. Currently git is widely used in the software development process. It allows developers to keep track of the codebase, in conjunction with other developers on the project.
  • If you are a senior, it is really necessary to master the use of git during development. I will list some tips to be able to work with git like a senior. Remember it’s just a tip, but the author is a fresher.

Use Branches.

  • One of the main functions of git is the use of branch. It is a separate line of development, allowing you to work on new functionality or fix-bugs without affecting the main codebase. It is indeed extremely useful to keep the codebase stable during the development of a project.
  • If you are a senior, you need to be familiar with the development strategy, manage the branch , and use it most effectively. For example, use branch for a function, where you create a new branch for a new function in development. After completing the function, will be merged into the main codebase.
  • Command to create a new branch:

  • When executing the command, the code will be switched to the new branch.

Use Version Control effectively.

  • Some things are extremely important when using version-control:
    • Commit code frequency.
    • Write notes for your own code
    • Pull requests to see what code has changed from other members
  • Commit-code frequency will give you and your team an overview of the functionality or fix-bug. This also makes it easy to roll back to the previous Version of the code in the event of an error.
  • Writing descriptive is a good idea for the purpose of clearly explaining the change of each commit. Help other team members understand the history of the codebase and why this change occurred.
  • Pull requests are a way to cross-review to provide feedback, before the code is merged into the main codebase.

Use command line.

  • There are a lot of commands in git, but there are a few that are commonly used: commit pull push merge rebase
  • Command commit is used to save changes of code on local repository. For example, if you want to commit the code, run:
    • During the interview, sometimes there will be a question if there is no wifi for commit code → can you help me answer.

  • Command push is used to send commits from local to remote repository, like gitlab or github . For example, if you want to push the code, run:

  • Command pull is used to fetch and merge changes from remote repository. For example, if you want to pull the code from the main latest branch, run:

  • Command merge is used to merge one branch to another branch. For example, to merge branch A into branch main, run:

  • Command rebase is used to apply changes from one branch to another. Rebase is useful and clear for tracking history and avoiding merge commits. To rebase branch A onto main, run:

Using Git GUI

  • The GUI is extremely useful for visualizing and interacting with the git repository. Some tools like GitKraken, SourceTree also provide Visual Representation of the repository, and allow you to act directly on the GUI.
  • The GUI is suitable for a beginner or needs a visual approach to version control. A senior in addition to using the command-line, being proficient in using the GUI is also extremely important.
Share the news now

Source : Viblo