A Better UI (CLI) for git

The books did make me think. A lot. A lot about a tool I use everyday…
git http://git-scm.com.

Git is sweet tool. But, the UI could use some love.

The UI can be confusing and inconsistent for newbies. In fact, even after three years of using git, there are commands I still find confusing (do I want git revert or git reset… and does it need –hard, HARD, –cached, HEAD, –, or something else?).

An interface should never be a by-product of the implementation of the system. This is where the Git UI goes wrong.

The command git reset is a good example. I use git reset to undo things. But, its called “reset” and has a bunch of strange parameters which have to do with making writes to the git index. In order to undo changes properly, the reset command requires the user to have a clear understanding of the guts of the git index. This should not be the case for a common command, like undo.

git status is cluttered with commands telling me how to undo things “use git reset HEAD <file> to unstage”. If the commands were easy enough to remember in the first place, we would not need to clutter the status output with reminders. And, what does “changed but not updated mean”? I did update my file! Do you mean “changed but not staged”? Lastly, I would like to humbly request a few fewer “#” characters. Just a few. Please.

Here is my shot at re-creating a few parts of the Git UI. My hope is that all of these commands become part of git one day and that git becomes easier for new users and forgetful intermediates like me.

Unstaging Files

Ooops. I staged a changed that I do not want to commit.

# Remove one file from the stage.
# Instead of git reset HEAD -- file, just type:
> git unstage FILE
# unstage all the files you have in the stage right now.
# Instead of git reset HEAD, just type:
> git unstage

Undoing changes I have made:

Ok. I tried something. It does not work. Just get me back to the last commit.

# Undo all the changes I made to working directory.
# Automatically save the user's work in a stash, then
# Instead of git stash; git reset --hard HEAD, just type:
> git retreat
All files changed back to their state at the last commit.
Your work has been saved in stash@{1}.
# Just undo the changes I made to one file.
# Automatically save a stash of the user's work first
# Rather than git checkout FILE (side note: why is it not git reset FILE? or is it?)
# Instead, just type:
> git retreat FILE
The file was changed back to the it's state at last commit.
Your work has been saved in stash@{1}.</pre>

Deleting Files

Let’s get rid of git rm. Lets not even tell newbies about it. Just delete files you want from your project, then:

This replaces the more confusing error message that git shows users now:

Error 123: Look! Another stupid user is _trying_ to learn git.
You should have known to type this first:
> git config --global user.name "Jon Saints"
> git config --global user.email "gmail@gmail.com"
You are a git DUFUS!! Just give up now. Seriously.

Switching branches

# I switch branches with the checkout command. Its ok, but what if we had:
> git switch BRANCH

Showing things I have changed

This is one of the most important parts of git. And, it is confusing.

# What is the output? Can you remember which is which?
# git diff
# git diff HEAD
# git diff --cached or git diff CACHED?
# Instead we can...
# Show all changes from the last commit
> git diff
# or
> git diff HEAD
# Show difference between the stage and my code
> git diff STAGE
# Difference between my stage and last commit
> git diff STAGE HEAD
# Difference between two branches or revisions
> git diff branch1 branch2
> git diff AD34E BCDE543