Working with git on a day to day job
When working with git, it’s not uncommon to see something like the following in the user’s
alias ga="git add ."
alias gc="git commit"
alias gl="git log"
alias gla="git log --oneline --all --graph"
And so on.
And to consider another use case, it might have happened to you that you needed to stage some specific lines of a file or even a single line for that matter. I have dozens of similar experiences when I’m trying to include all the relevant changes in a single commit with a good commit message.
Why does git need a user-interface?
This may not be much of a trouble at first, but when your repository gets bigger and bigger it becomes daunting, especially when you have a lot of “changes not staged for commit”.
That being said, I consider my alternatives. Which brings us to the necessity of a user-interface for
What options do we have?
There are a lot of options and here’s a list to name a few. But I don’t think we need to get our hands on every single one of those. I have experiences with 2 of them, & I’m gonna share it with you.
Very cool design and an elegant layout, with lots of features.
You can expect to get the most out of
git once you experience this Graphical User Interface as depicted below.
I admit that I was reluctant to give it a shot when one of my managers recommended it. But after spinning it a few times here and there, I wasn’t willing to let go.
You get lots of flexibility regarding how you want to do what you want to do (version source control speaking).
If you want to add/stage a single line in a whole file, you got it. If you want to add a hunk, you still got it. And these are not all. It comes with lots of features and it is also free to some extent.
- Flexibility to stage a file as you wish. Either staging a single line, by hunks or the whole file.
- Awesome diff view when a conflict occurs.
- Beautiful tree view when viewing the logs.
- It is free for the general use case.
- It is full-featured for a git client and growing by the day.
- It updates regularly and notifies about the latest features and bugfixes.
- It consumes a lot of memory.
- It doesn’t fit well when working on a directory mounted from
sshfs. Changes are not tracked well enough and even committing often leads to lagging. Especially if you don’t have a stable connection.
- Regular updates were a pain for me as I was satisfied with the current features and I couldn’t turn it off.
- I’ve had some crash experience when the git working tree gets bigger and bigger and it was one of those ugly C programming language “core dumped” that was irritating.
- It doesn’t allow one to use the application beyond 10 days unless you log in before the period ends.
- It requires way too much access when trying to login via Github as depicted in the picture below.
I am glad to be introduced to such a great tool & I would recommend checking them out.
This little fellow has been around since 2006.
Although it didn’t release its first stable version until 2012.
But aside from all that history lesson, here’s what you would expect to see when using
As you can see from the above picture,
tig shows the tree similar to what you would expect from
git log --oneline --graph --all.
It’s the desired/preferred way when you’re looking at a project.
It is also very fast as it is written in the C programming language. I would use
tig instead of gitkraken in one of the following two scenarios.
- I am low on memory and I don’t want to add another burden to my OS by opening another high-consumption load.
- I am on a remote host and opening a graphical application is not an option. Not unless some other approaches are considered.
When working with it, here are a couple of hotkeys you might use a lot.
statusin the current working tree.
uto stage/unstage either a hunk or a file, depending on where your cursor is. Note that
tigis not able to stage a single line the way gitkraken does.
Cto commit the staged files. Which opens your favorite editor that you specified in
Rto refresh the working tree after a change has occurred since you opened
tig. It doesn’t refresh itself automatically after opening.
qto quit or to return to the last window.
hto show the list of hotkeys.
kto navigate through a file.
?to search forward and backward just like in
To sum it up here’s what you can expect from using
- It is super fast, just as you would expect from a git client.
- It is simple and no fancy work or configuration is needed.
- Hotkeys are simple and intuitive and you wouldn’t need a lot of time memorizing them.
- Everything is clear and concise, as well as elegant.
- Some of the features of a usual git use case is missing. e.g.
checkoutto a [new] branch.
- You can’t stage a single line as you can in gitkraken.
- Sometimes I get lost when working with hotkeys.
- You don’t get to change anything once you’re in the editor after invoking the commit command. Staging or unstaging more files is not an option when you’re inside the editor after pressing
In the end it’s up to you to decide which user interface to use, if at all. But for my experience, I’d choose gitkraken unless there’s a memory shortage or graphical limitation.
But both of these tools are amazing and I strongly suggest you check them out. Once you get a taste of them, it’d be hard to live without them.
I sincerely appreciate the time you put into reading this piece. I hope you get something from it as you invested the most precious asset of yours: time.
Stay tuned and follow me if you enjoyed the above content and feel free to check out my other contents if it pleases you.