You don’t need the Git CLI

Please wait a while before starting… bashing Me.

CLI

You should learn the CLI thoroughly and it is still important to know what to do if, for some reason, the GUI you are using has some problem. Besides, that was, clearly clickbait… right?

living outside the CLI

I use VSCode with Git Lens to the point that I have no idea what I’m saying here is just VSCode and what is done through Git Lens. But if you’re using VSCode, you’ll only need to install Git Lens to gain access if you haven’t yet.

Another extension worth mentioning is the traditional commit, which lets you write beautiful commit messages and lets you remember each part of the commit according to the traditional commit specification.

the tool you will use

If you gave up, if I say something and you can’t find it in your VSCode, it’s probably a lack of Git Lens installed.

You have an entire tab dedicated to Git.

It shows tracked and untracked files, it shows all repositories if you have multiple in your workspace, and it also shows branches, repositories, stash… basically everything you need and many more.

to use branches

Some people are missing it, but on the bottom corner:

with branch and sync button in the bottom left corner of vscode

You can sync changes easily (it already shows you whether something is incoming or outgoing).

If you don’t have any transforms, it also makes it clear that you have changes to push or pull:

1 sync change to push

1 sync change to pull

So, no more excuses for “I forgot to push”.

And you can easily change branches or create new branches by clicking on the branch name button.

to do

If you’ve never checked out, you’ll probably see something like this if something changes:

Source control section with change to list view

The first thing I recommend is to switch to tree view (it’s bunch of line icons above the message input). You should see something like this:

Source control section with changes in tree view

files with M Means “modified” files.

files with U Means “untracked” files (new files).

files with D Means “deleted” files.

You can also see the colors of those letters.

They show you new (green), modified (blue), and deleted (red) files.

And (if you have any kind of lint and other extensions that find it) they also show you if they have warnings (orange) or errors (red).

dealing with changes

When clicking or hovering you will see:

button/click on hover

You can go to the file, discard the changes, and stage.

When clicking or hovering over the line “Change” or “Phase change”:

change with button

step change with buttons

You can stage/unstage all files, discard all, or even hide them.

Also, when you click it, it opens the changeset:

change tab open

(You can use inline transformations if you like it in the “…” (three dots) button)

One feature that makes it worth it

So far, it’s neatly shown all but all that you can easily do in the CLI, and some people like it that way, but it’s something that might make you think twice. And dare I say it: it really changes the way I code!

Suppose you have this:

File with lines containing errors and a line.log with console

Lots of errors, but you have a working line that will work on its own… do you commit the whole file with all breaking errors, or… what do you do?

Well… as easily as two clicks you can… just step one row!

Right-click on the line:

right click open range commit section

Then left-click on “Stage Selected Range” (which can be multiple lines selected):

Only the selected line is staged

Now just commit the line that is committing itself without touching any commits you don’t want to touch now.

(Yes, I know it’s possible to do this with the CLI, but nowhere near as easy!)

want more?

It might be a bug that’s actually a feature… but you don’t even need to save the changes you’re saving! Yes. You can stage unsaved changes! I

unsaved line staging

after discarding changes

(As you stage changes, the left panel shows what’s staged. When you discard your changes, it picks up that difference.)

I’ve found that because I usually force the filters to “fdescribe/fit” tests and commit those “f”s when I used them. So I just changed the line and staged, and that’s when I noticed I hadn’t even saved it.

So if you need to make a little change to make sure you can open a commit and it works, you can do them without saving. Change, Step, Undo.

Luggage and other things management

There are lots of other things you can do, especially with regards to syncing, changing, deleting, and renaming branches, and hiding.

Don’t forget to check out the palette command to see other cool things you can do.

My favorite is to cherry-pick (use the GitLens one for this).

You can also navigate the changes made by commit, on each file.


I probably forgot to mention a lot here… so ask! And leave yours too!


Unsplash. On cover photo by Praveen Thirumurugan

For anyone interested:

Leave a Comment