Using git GUI in Git visualization tutorial

Time:2020-11-21

Git has been briefly introduced in the article git introduction, but the theoretical knowledge is too boring, coupled with my professional knowledge is not solid enough, so beginners will still have great difficulties in the use of GIT. Although I prefer git bash to operate git, most of my friends who just want to use git for version control and team development still prefer visual interface. Therefore, this paper introduces the use of GIT GUI, the official visualization tool of GIT, and tries to make pictures and texts, so that all friends who are exploring git can quickly get started and use git for project development.

1. Create a new version library locally

First of all, we open git GUI, which is such an interface, select the first item and create a new version library.

Then select the project path that you need to do version management. I chose a logindemo project.

When you create the version library, you can see an additional. Git folder in the path of the project

In Git GUI, if there are files in unstaged changes, first click stage changed to add the uncached changes to the cache, and then click commit; otherwise, you need to click rescan to scan the changed files in the project. Note: the submission description must be filled in, otherwise it cannot be submitted.

After the submission is successful, we can see our submission history in repository > visualize all branches history. At this point, the local version library is created successfully.

2. Submit project to remote

In the previous step, we have set up a local version library using git, and then we need to submit the project to a remote server so that colleagues or other partners can participate in the development. General open source projects use GitHub as a remote server. In fact, after the local resume version library, you just need to click push to upload directly. However, we have not yet established a local git with GitHub and set up a security protocol.

First, we need to have our own GitHub account, and then create a new repository on GitHub, also called logindemo (which can be different from the local project name).

In Git GUI, select remote > add to add the remote server. There are two ways to fill in the remote server information: fill in the HTTPS address or SSH address, which corresponds to the HTTPS and SSH address of GitHub project. SSH is recommended.

1. HTTPS address

This requires entering your GitHub account and password, which means that you can only work on your own projects in this way.

2. SSH address

This method requires authorization settings. In the menu bar of GIT GUI, click Help > show SSH key > generate SSH key to create a key.

Then add it to the personal settings of GitHub. The title is optional and can be distinguished by home, company, etc.

Add remote server information.

Next, we can click push to submit to the remote client directly in Git GUI. After refreshing GitHub, we can see that the project is already in the repository.

3. Download updates from remote

Assuming that many people participate in the project development, everyone only push to the remote, regardless of the progress of other members, such a development mode is undoubtedly problematic. Our best practice is to fetch the current progress from remote to remote, and then push it to the remote after merging with the current project progress. Open git GUI and select remote > fetch from > logintest in the menu bar to update from remote server to local, but it has not been merged with your current project.

4. Merge to resolve conflicts

After remote fetching, select merge > local merge in Git GUI and select tracking branch.

If there is a local method named finduser, and the name of the method in the remote server is changed, for example, to findpassword, the merge encounters a conflict. You can right-click the blank part and select to keep the local version or the remote version to merge (the green code in the figure indicates the conflict part).

5. Clone GitHub project to local

Select clone the existing version library on the main interface of GIT GUI.

Source location is the address of the project in GitHub. As in the second part (submitting the project to remote), you can select either the HTTPS address or the SSH address. The target directory is the path where the project is stored locally. Click clone to successfully clone the project from GitHub to local.

This article introduces the use of GIT GUI in Git visualization tutorial. For more information about git GUI, please search the previous articles of developeppaer or continue to browse the related articles below. I hope you can support developeppaer more in the future!