5 Git Tips To Improve Your Workflow

0
689

Git is an open-source version control system that significantly improves the situation of formalized source code management. It has made source code management more comfortable than before. But like many other technologies, Git’s relatively shallow learning curve promotes its wide application.

At the same time, it also provides many features and options, which can easily overwhelm beginners. There are many different ways to improve workflow in Git, such as using code review tools.

If you are looking for a way to save your valuable time, then this is for you. Here are some most popular Git tips to help make your workflow more efficient and less hassle.

5 Tips To Improve Your Workflow

Git Tips To Improve Your Workflow

1. Handle Branches Properly

You can handle different branches in your repository. The branches in Git are equivalent to the directories on your computer. In each branch, Git registers all the changes developed by those who use it, and it also allows operations between the branches, such as their merge, for example.

Branches are generally used to develop functionalities isolated from each other. By default, the repository is created with a branch that is configured by default, called master.

In managing branches, you should consider, among other things, the following:

  • Any repository has or should have at least two branches: one known as master, which is the production branch, and the second branch, derived from it, in which new functions are developed, or bugs found in the master are corrected. This branch is often called to develop.
  • You can create all the branches that you consider, for example, to develop other functionalities and correct details of the develop branch. Therefore these branches are derived from it.
  • Consider keeping the branch where you work updated with the branch it came from.
  • Avoid mixing changes from different branches.

Types Of Branches

There are various types of branches you can implement with git workflow, including the following:

A. Feature Branch

If you want to start a new feature, such as adding a payment gateway or epayables system, to your project, then you can do so.

You can create a new feature branch, which is based on switches and ‘develop’ to it. After your hard work, you can finish the payment-gateway feature, switching it to branch ‘develop.’ The Git-flow then deletes the obsolete feature branch, checking to the “develop” branch.

B. Release Branch

If you’re releasing the ‘develop’ branch, begin a release with the use of git release command, creating a release branch from the root ‘develop’ branch.

After finishing the release, both the “master” and the “develop” branches are merged so that the production code and all feature branches follow the latest code.

C. Hotfix Branch

Hotfix branch refers to mischievous bugs, appearing after thorough release testing. When starting a hotflix branch, it is somehow the same with release branch. However, this branch follows the master branch as the basis, while release follows the develop branch.

When finishing a release, the master and develop are merged to prevent the bug from slipping to the next release. For easy reference, the hotflix is tagged with the branch deleted and “develop” checked accordingly.

2. Create aliases for the git commands you use the most

When using Git, you have to type several commands daily, such as upload and download changes, and other commands that can get repetitive.

To increase productivity, it is suggested to create aliases for the git commands coders use the most. The alias is a “name” assigned to a Git command that is shorter than that command, which allows us to execute the same action with less typing; that is, it helps to save time.

If you are typing any commands, Git does not provide auto-completion. If you don’t want to type some orders completely, you can set aliases for them using git config. For example:

$ git config –global alias.br branch

$ git config –global alias.st status

$ git config –global alias.ci commit

So from now on, you write git br instead of git branch and so on for the others in the example. There is no standard for creating aliases; it all depends on whether you feel comfortable with them.

As you increase your work with Git, you will frequently use other commands; if you feel comfortable, do not hesitate to create aliases for them.

3. Gather commits into one

In most cases, there are projects with many branches, several collaborators, and therefore many commits. To save time and make work less tedious, you can join commits.

This alternative requires you to take into account a few things:

  • Mixing changes from different branches are not recommended.
  • Avoid as much as possible that the changes are of different types, thus preventing inconveniences if, for any reason, you must later undo the changes.

Take a look at this example of basic branching and merging using a git workflow:

  • Work on a website.
  • Create a new user story branch you are working on.
  • Work in that particular branch.

You will receive a notification of another issue that would require a hotfix. You can follow these steps:

  • Switching to the production branch is recommended
  • Add the hotflix by creating a branch.
  • After it is tested, you can merge the hotfix so you can push to production.
  • Finally, switch back to the original user story.

4. Use some graphical interface to handle Git

Perhaps using the terminal to manage version control can be somewhat complex, especially if you start with version control.

That is why you should bear in mind that, to manage projects in a more graphical, visual, and intuitive way and speed up your work, you can use some graphical Git clients.

Many of them are free, open-source, and there are them for any operating system. On the Git wiki, you can find a complete list of Git clients.

The graphical interfaces adapt to different workflows; that is, some include more functionality than others. However, none can be considered better than the other, only that each one is adjusted to the users’ needs.

5. More about commits and other recommendations

  • Commit frequently, don’t be afraid to commit unfinished things, and have them show up like this in history.
  • Always review your changes before uploading them, and make sure that only what you need goes into commitment.
  • The commit message should be concise but at the same time informative.
  • Do not upload changes directly to master, as long as it does not deserve it.
  • When starting a new work session, you should fetch or pull to bring you the latest changes. In this way, you avoid conflicts in the future and avoid overwriting the work of others unnecessarily.

Final Words

There are so many Git workflow improvements that you can implement to make your team more productive and efficient.

You can use the tips mentioned earlier to improve your workflow better than before. These ideas can help you to maximize your potential and ability to complete projects faster more efficiently.

Read Also:

Author: John Brooks

14