4 de agosto de 2015

Pimp my GIT: Improving GIT command line (cli) interface and usage


Following up yesterday's post, here goes another set of tricks I have done to my GIT setup.

To begin with, add this code to yhe .git/config file of your git repo clone:

Once you do that, you'll see things like colors when running a "git status":

You'lll also be able to use git command shortcuts, like:

- "git st" instead of "git status"
- "git ci" instead of "git commit"

Logs will look much more sexy and colorful.

You'll see diffs with colors and with a much more user-friendly format:

When running "git branch", you'll see the current branch highlighted and the local branches clearly marked in yellow:

And remote branches in green:

That's all for today, folks!


3 de agosto de 2015

Setting sail towards an awesome GIT experience

Here goes a bundle of tricks and treats for a better GIT experience:

Some years ago I found something like that I'm going to show you and, eventually, I assembled a series of scripts (some things I did, some things that I found on the web); they do various things with bash, which are sweet.

What things?

  • Automatically detects if you are in a folder belonging to a git repo, and, in the case it is, the prompt display relevant information that is repo: branch and state. Example:

In this case depicted, I was on the branch "master" and I had modified files (hence the "m") and files I deleted (hence the "d").

  •  Another cool thing is to have tab completion (that pressing the tab key with a half-written command you get all the options to complete the command -or the command being automatically completed if there was just one choice-).

Imagine that applied to branch names, git commands and Django commands (like "python manage.py runserver" for example). Sweet, isn't it?

  • Some other sweetnesses included:
    • Increase the size of the history of bash, but eliminating duplicates, so to do "ctrl r" in the console, we can look at the history of the commands that we did and found interesting results.
    • A long list of colors defined to directly save them in defining the prompt.
    • Etc!

The scripts, give me the scripts!

The first two put them right into your home folder.
The third file, call it the way your system get it right. For me it is .bash_profile. Put it right in your home with this name or copy its contents to your existing bash config file.
If you use Linux, you can do the same with .bashrc.

Note that the files have an underscore in the beginning of their filenames. Remove this underscore when placing the files, letting the names begin with a dot, as they are hidden files.

Cheers and May the bash be with you!!