Hi all. I want to share with you my search for the best Git GUI for Linux. My journey with git started 5 years ago at my first job, when I learned how to use git form bash. In rest of my developer career, I started using Windows and LabVIEW and naturally I started using git GUI for Windows Tortoise GIT (https://tortoisegit.org/) . And I like it. It has a lot of advanced functionalities simply laid out to use with simple click. So, I wanted to find something similar to Tortoise Git but for Linux. It this search I came across the ungit (https://github.com/FredrikNoren/ungit) and ungit is maybe the easy way to use Git with Linux Git GUI. So, lets explore ungit.
For this blog I’m using the Manjaro KDE OS, so installation process is very simple. We need to follow the installation paragraph https://github.com/FredrikNoren/ungit and just open the terminal and type:
npm install -g ungit
If there is some privilege problem just add sudo before:
sudo -H npm install -g ungit
There is another way to install ungit and that way includes AUR (Arch User Repository). You can go to next AUR link, download snapshot and then extract it with:
tar -xvf <Downloaded snapshot folder>
then enter extracted folder and install snapshot with:
cd <Extracted Snapshot Folder> makepkg -sic
And now you have ungit installed on your local machine.
You can start ungit by simply typing ungit in terminal. Ungit will open in your default web browser because it’s base on node.js. The active directory is the same directory form your terminal, so if you just open terminal and start ungit, ungit will be opened it your home directory. In my case that is /home/linuxbln/. Home folder, usually, isn’t git repository, so we are greeted with next screen:
Left from ungit log there is current folder path and with this we can navigate to some folder that is already git repository. Also, we can create new git repository in the current folder simply by pressing Create Repository and close existing remote git repository by adding URL and destination folder and pressing Clone Repository.
Create git repository and first commit
Let start, I have created folder TestGIT on the Desktop and first order of business is to create git repository inside this folder by clicking on Create Repository.
When new file is created inside TestGIT directory it will be shown on ungit as well.
With check mark beside file name we can adding our new file in staging area or simply we are doing git add. We have indicator that file is new and now we can discard changes or we can just stash them. If we are ready to make a new commit we need to fill up Title and Body field and then we can press Commit.
If you haven’t use git before you will be greeted with next error.
Git needs to know how you are when you are doing the commit and we need to provide the info by adding user name and email in global or local git config. As shown on ungit error message we can add this info with next commands:
git config --global user.email "email@example.com" git config --global user.name "Your Name"
For adding this information to local git config you need to change –global flag to –local flag. And now we can finish our first commit and then ungit will look something like this. Commits are represent as circles and we can have detailed look in commit by clicking on circle.
Checkout older commit
To checkout the older commit we first need to have couple of commits, so lets create two additional commits. Ungit should shows us something like this:
If we click on older commit (the colored circle) we can see what are our options.
So this is no good for us if we have just to check out our older commit and look inside. But, what are our options if we click on plus sign beside commit circle.
We can create new branch and/or new Tag so that we can and then we have option checkout.
And now we can checkout our older commits. With this we have basic git functionality, so now lets go to something more complex, like merge with conflict.
Merge with conflict
First we need to create branched commits so that we are able to do merge with conflict.
To merge master to TestBranch first we need to be checkout to TestBranch. Then we need to click on master branch to reveal new options.
Now we have merge option that we can select. If there is some conflicts, ungit will shows us something like next windows.
Ungit is now waiting for us to resolve conflicts. By default we have next case.
We can now open the conflicted file with our favorite text editor and manually do our merge. The other, more interesting way is to integrate external diff merging tool in ungit like meld or kdiff3, but I will cover this in next blog post, so stay in touch. When we are satisfied with our merge we need to set that our conflicts are resolved and then we can make our merge commit. We have automatic commit title and body added by ungit but we can change it or add some additional merge info.
For me, ungit provides very good graphical user interface for git in Linux. With addition of external diff and merge tool, I think that ungit can have everything that you need, easier git experience for regular R&D engineer.