This article, the second in a series on Git, introduces you to your experience with Using Git with visual tools. There are a variety of visualization tools. My own is Github Desktop. Sourcetree will also be introduced in this article.

Command line or visual AIDS?

The command line is the native way to use Git, so when we learn Git, we will use the command line to understand how Git works. When using visual tools, it is important to be aware of what commands are actually being run in the tool. Always display full console Output (Tools -> Options -> General -> Repo Settings) Turn it on to display the corresponding command every time a Git operation is performed. When used, the picture is as follows:

Once you are familiar with Git’s commands, you will understand the shortcomings of the command line. Here are just a few of the features I think you need to use visualization tools to improve your experience at work:

  1. Diff comparisons between different versions of code
  2. Look at the commit history
  3. Functional integration with the development environment

Let’s talk about how I solved the above requirements.

The diff is

If you’re using Github Desktop or Sourcetree, comparing commit differences is just a click away. If used in conjunction with the command line, git diff and Git DiffTool can be used. According to Git’s instructions, the latter calls the former internally, so use Git DiffTool. You can set up one of your usual comparison tools as diffTool. In the case of vscode, you need to modify the.gitconfig file (located in C:\Users\YourUserName\.gitconfig on Windows) and add the following:

[diff]
    tool = default-difftool
[difftool "default-difftool"]
    cmd = code --wait --diff $LOCAL $REMOTE
Copy the code

Look at the commit history

Github Desktop and Sourcetree both provide intuitive viewing of submission history, nothing special.

Use in conjunction with the development environment

IDE usually provides git library file status check, so that users can easily know which files have changed during their development. In addition, vscode, which I’m familiar with, has a feature that makes it a great experience to use: if you hover your mouse over a line of code for a while, it will pop up details of the last change to the current line of code. This allows developers to quickly see what changes have been made to the code as they flip through it. This is done through the GitLens plug-in.

Github Desktop vs. Sourcetree

Both tools fulfill the main functions of visualization tools (function points 1 and 2 above), but they also have some advantages, listed below:

  • Github Desktop can be bound to Github accounts, which can bring great convenience to Github users
  • Sourcetree has more interface operations, building branches, pulling code can be done through interface buttons (pros and cons, beginners do not rely too much on interface)
  • The Graph column on the leftmost side of Sourcetree’s History screen is a good representation of the relationship between branches, which is not available on Github Desktop

This article is written here, thank you for reading! Hope you can share your own better experience!

Git experience (2) : Visual AIDS