Version Control – Git GUI
In this article we will take an introductory look at the Git GUI which provides a graphical interface for working within a repository. We will see its main components and look at how you could use it when adding and editing files.
Why use the Git GUI Tool?
In the previous article in this series I discussed the Git Command Line Tool. In that article I made the case for using the Command Line Tool over the GUI Tool when learning to use Git. The GUI Tool is useful though and once you have a handle on using Git from the Command Line I would recommend that you move to working with both tools in tandem. Some of the benefits of using the GUI Tool include:
- Easier access to many of the features of Git
- The visuals provided by the tool can make it easier to comprehend what is happening as you use Git for your version control
- You can see the status of your repository in real time without having to enter commands
- You can see several components at once in the various windows rather than running commands one at a time.
Git GUI Orientation
There are various GUI clients that can be downloaded and used with Git (for Windows clients see here). For this article we are going to focus on git-gui which comes with Git. The image below shows the interface when you open it in your repository:
We have a menu along the top which allows you to access various options and features. We can see the current branch at the top left corner of the screen. Unstaged changes are listed in the upper left panel and Staged Changes in the lower left panel. Buttons for common tasks for staged changes are provided to the right of the Staged Changes section. You have a large text box to enter your commit message in.
When we add a file to our project folder we do not initially see anything change in Git GUI. We need to click the Rescan button for Git GUI to check the status of the repository. In the example below we have added a new file to our project folder – utils.py – which will contain some helper functions for our script. After clicking Rescan we can see that the file has appeared under Unstaged Changes.
Clicking on the utils.py file in the Unstaged Changes section will bring up some information about the file. Here we can see that the file is not tracked and has not been staged. We can also see that the file is currently empty.
To track the file we just need to click the Stage Changed button. The file moves to the Staged Changes panel and clicking on the file we can see that it is now staged for commit. The information shows us that this is a new file.
To commit the file we simply add a commit message in the lower text box and click the Commit button.
We will make a change to our main.py file to import the utils.py module that we just created. The Git GUI client does not show any changes so we again click the Rescan button so that the changed file can be identified. This time we see that that the file was modified and we can see the changes that were made to the file. We could achieve this using a command in the Command Line Tool but the benefit here is that all we had to do was click on the file name.
Now we can click the Stage Changed button to stage the change, enter a commit message and click Commit to commit our changes. Easy!
When we have finished working on the project (for this coding session) we need to push the changes to our remote repository. This is easy with the Git GUI Tool – all we need to do is click the Push button, select the branches to push and the remote destination (‘origin’ in our case). These options should be pre-selected for you so you only need to click the Push button a second time to push the changes.
The Git GUI Tool provides an easy way to interact with Git to manage your version control. It does not require any commands to be entered and can be as easy as point-and-click. This is good for productivity but it also means that you can be clicking buttons without actually understanding what the software is doing. This will lead to problems if you need to troubleshoot. It is for this reason that I recommend that you start to learn to use Git via the Command Line Tool and then move to using the GUI Tool in combination with it.
There are a lot more powerful features available with the tool that we will explore in future articles. In the next article we will look at the use of branches.
- Version Control – Git GUI – 7th March 2023
- Version Control – Git Command Line Tool – 7th February 2023
- Version Control – Creating Repositories – 7th January 2023
One thought on “Version Control – Git GUI”
Great intro to the git GUI Jeff !
I think you have inspired me to actually install this now 🙂