A bunch of bash customization to make the shell feel like home
Shell
Switch branches/tags
Nothing to show
Latest commit 86ede42 Jan 12, 2017 @orefalo npm packages
Permalink
Failed to load latest commit information.
.config/fish
.grc
.gitignore
Readme.md
aliases.fish
docker-compose.fish
inputrc
inputrc.sh
javahome.sh
setup.sh
z.sh
zpath.fish
zpath.sh

Readme.md

image

##Introduction

g2 is your new git command line client. It provides

  • Smarter commands that provide guidance
  • Enforces a clean linear history
  • A cleaner alternative to stashing work in progress
  • Solves many of the typical issues faced by beginers
  • Introduces a set of two characters acronyms to speed up typing
  • Hide all complex commands and gives only what you need
  • bash completion with the TAB key
  • A smart git shell prompt
  • A set of predifined git defaults that greatly enhance the terminal experience

##Motivation

Git has a steep learning curve!

I see it every day, beginers have a hard time picking up git. Aside from the concepts, the command line is not easy. Aimed at people who know git, not beginers. it will Start talking about the index, rebase, remotes, tracking and you can read it in the blank of their eyes: they don't get it.

This project is an attempt to make the git command line a friendly place: it eases the learning process by fixing some of the most common mistakes and comes preconfigures with some of the best git extensions/recommendation for the terminal.

Typical problems & mistakes

  • Setting up ssh keys
  • Setting user name, email and preferend diff/merge tool
  • Confusing remote/branch with "remote branch"
  • Dirty history with lots of unnecessary loops
  • Letting to user rewrite his history without warning
  • Not getting the principles of the staging area
  • All kinds od issues switching branches with untracked files
  • checking out origin/branchN insead of branchN
  • Did I mention rebasing ?

##Instalation

A brew package will be released soon.

In the mean time, please clone the repository and souce the .sh scripts

The scripts introduce the g alias.

$ g
Usage:
	setup - configures user, key, editor, difftools
	key <?--gen> - displays/generates your ssh public key
	init <folder> - init a repository
	clone <url> - clone a remote repository

	abort - aborts any rebase/merge
	am - amends last commit with staging area
	br <?branch> - list or create branches
	bs - bisect
	co <branch> - switches branch (either local/remote)
	cp <commit> - cherry-pick
	ci <?params...> - commit
	df/dt <?params...> - compares files
	freeze/unfreeze <?file> - freeze/unfreeze to staging area
	gc - garbage collects: run fsck & gc
	gp - grep
	ig <file> - adds to gitignore & removes from source control
	mg <?params...> <branch> - merge
	mt <?params...> - fixes conflicts by opening a visual mergetool
	mv - move (rename) a file
	lg - displays commit log
	ls <?params...> - list files under source control
	panic - gets you back on HEAD, cleans all untracked files
	pull/push <?opts> <remote> <branch> - deals with other branches
	rb <?params...> <branch> - rebase
	rm <params...> - remove
	rs <params...> - reset
	rs upstream - resets branch to upstream state
	remote <?params...> - remote
	rv <commit> - revert
	submodule <?params...> - submodule
	st <?params...> - status
	sync - syncs working branch: fetch, pull-rebase & push
	tg - tag
	track <?upstream_branch> - shows/set tracking
	wip/unwip - save/restore work in progress to branch

A recommendation… alias git to g with the following:

alias git=g

##How to use

Aside from providing two letters shortcuts for most git commands, g2 has some differences which should be highlighted. This sections highlights the main differences:

###Setup

Git setup is such a pain. Paradoxaly it happens only once!
But forcing a beginer to go though intensive documentation readings is not be best way to get them up to speed.

So here comes g setup and g key to the rescue:

$ g setup
Please input your full name : Olivier Refalo 
Please input your email : orefalo@dummy.com 
Please input your editor (vi): vi
Generating SSH keys...
Generating public/private rsa key pair.
Your identification has been saved in /Users/orefalo/.ssh/id_rsa.
Your public key has been saved in /Users/orefalo/.ssh/id_rsa.pub.
The key fingerprint is:
57:60:84:fa:0e:3b:96:12:15:2e:f3:d5:30:ce:aa:4f orefalo@dummy.com
The key's randomart image is:
+--[ RSA 2048]----+
|         o+      |
|      . +. .     |
|     . = +  .    |
|    o + + ..     |
|     = +S .      |
|    . + ..       |
|     oE=         |
|    o.= .        |
|     +..         |
+-----------------+
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDDYUTgzU9zjsdda9WBEED5bH+SVMq5bYoIxPSzop2IqUBoyyOlRdHt4dy2r/MWiB2eKQOQmPRE7SeawhFWYbCwEdi6BtEe8m4PiZd3OIRV13TlPj54Hi6Q1Ab8emEAH026L4kwef46+j0aJf/7tZzUw/uZW9Wrnf1VN+J1VlWvmYaG9JpPBuatAlTV9rhCeQ2WO39KYWVYJxH1mO0zPEpuTBojji7HYJtlS4OCKgY9mCVBPiUzzLfmrlIhZz+k5rMWv6i4tQtats23qtHEOi9GxJm4+TSGLwM89/C186CJ+8Yx0g/c2DIbVtPm2VMwUayu8wU4GfBHtOwin4cLWsvT orefalo@dummy.com

At anytime, you may display your ssh key with:

$ git key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDDYUTgzU9zjsdda9WBEED5bH+SVMq5bYoIxPSzop2IqUBoyyOlRdHt4dy2r/MWiB2eKQOQmPRE7SeawhFWYbCwEdi6BtEe8m4PiZd3OIRV13TlPj54Hi6Q1Ab8emEAH026L4kwef46+j0aJf/7tZzUw/uZW9Wrnf1VN+J1VlWvmYaG9JpPBuatAlTV9rhCeQ2WO39KYWVYJxH1mO0zPEpuTBojji7HYJtlS4OCKgY9mCVBPiUzzLfmrlIhZz+k5rMWv6i4tQtats23qtHEOi9GxJm4+TSGLwM89/C186CJ+8Yx0g/c2DIbVtPm2VMwUayu8wU4GfBHtOwin4cLWsvT orefalo@dummy.com

Need to regenerate the key pair? The process is equaly user friendly:

$ git key -gen
Regenerate SSH Key (y/n)? y
Generating SSH keys...
Generating public/private rsa key pair.
/Users/orefalo/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Your identification has been saved in /Users/orefalo/.ssh/id_rsa.
Your public key has been saved in /Users/orefalo/.ssh/id_rsa.pub.
The key fingerprint is:
57:60:84:fa:0e:3b:96:12:15:2e:f3:d5:30:ce:aa:4f orefalo@yahoo.com
The key's randomart image is:
+--[ RSA 2048]----+
|         o+      |
|      . +. .     |
|     . = +  .    |
|    o + + ..     |
|     = +S .      |
|    . + ..       |
|     oE=         |
|    o.= .        |
|     +..         |
+-----------------+
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDDYUTgzU9zjsdda9WBEED5bH+SVMq5bYoIxPSzop2IqUBoyyOlRdHt4dy2r/MWiB2eKQOQmPRE7SeawhFWYbCwEdi6BtEe8m4PiZd3OIRV13TlPj54Hi6Q1Ab8emEAH026L4kwef46+j0aJf/7tZzUw/uZW9Wrnf1VN+J1VlWvmYaG9JpPBuatAlTV9rhCeQ2WO39KYWVYJxH1mO0zPEpuTBojji7HYJtlS4OCKgY9mCVBPiUzzLfmrlIhZz+k5rMWv6i4tQtats23qtHEOi9GxJm4+TSGLwM89/C186CJ+8Yx0g/c2DIbVtPm2VMwUayu8wU4GfBHtOwin4cLWsvT orefalo@yahoo.com

###Basic commands

Exit git add and git rm, with g2 you freeze a state!

st,lg freeze, unfreeze, ci am

###Work in progress

wip unwip

###Branches

about rb co br panic rs

###Working with remotes

sync, track, fetch, pull, push, abort

##List of Commands

abort

Aborts either a rebase or a merge.

am

Amends last commit with contents of the staging area.
Won't ament if commits were sync with the branch.

br <?branch>

Displays the list of branches, local and remote.
Can create new branches if given a branch name.

bs

One of git best tool: bisect

clone

Clones a remote repository, wires to git clone

co

Switches branch (either local/remote)
extremely strict - won't let you checkout if you have changes or untracked files

cp

Cherry picks a commit from another branch, same as git cherry-pick

ci <?params...>

no wip

  • commit

df <?params...>

Compares files on the console, wires to diff

dt <?params...>

Compares files by opening the default diff GUI, wires to difftool

freeze <?file>

Takes all modified, deleted and untracked files to the staging area.
Note that you may also give it the file to stage.

gc

Repository maintenance: runs a structure check fsck followed by a gabarge collector gc

gp

Searches commits, same as git grep

ig

Adds to gitignore & removes file from source control

init

Creates a local repository, wires to git init

key <?--gen>

Displays the public ssh key.
Give it the --gen flag and it will generate a new key.

mg <?params...>

Merges branches, same as git merge

mt <?params...>

Fixes conflicts by opening a visual mergetool

mv

Moves (renames) a file under source control. same as git mv

lg

By default, displays commit log in a pretty colorized format. Any extra parameter wires to to git log.

$ git lg
* adbd444 - docs wording improvement pass (3 days ago) <David Greenspan>
* 2edb152 - make tests work in IE 6-10, MobileSafari (3 days ago) <David Greenspan>
*   7a05b13 - Merge pull request #64 from skalb/devel (3 days ago) <matt debergalis>
|\  
| * 9ebb67a - Function passed to Meteor.ui.render must return a string. (3 days ago) <Sameer Kalburgi>
* | e2eadee - Use correct variable name when logging a less error (3 days ago) <Josh McArthur>
* |   32266f5 - Merge pull request #62 from milesmatthias/docupdate (3 days ago) <matt debergalis>
|\ \  
| * | 6d57f14 - Added a note about how to read the docs locally, since it took me a while to figure out how to do it. (8 days ago) <Miles Matthias>
* | | d28ed89 - This is allow any user added script in their header to be able to use the libraries in Meteor. For example including a plugin would have to be always written a
* | |   7d269cd - Merge branch 'http' into devel (3 days ago) <Nick Martin>
|\ \ \  
| * | | cde4a4a - (origin/http) First pass at HTTP docs. (3 days ago) <David Greenspan>
| * | | 0f2673f - initial commit of HTTP package (4 days ago) <David Greenspan>
|/ / /  
* | |   e1a557f - Merge branch 'test-fixups' into devel (4 days ago) <Nick Martin>
|\ \ \  
| * | | d7fe7c9 - have test driver report FAIL if exception anywhere (4 days ago) <David Greenspan>
| * | | e68f9d1 - Remove old busted selenium tests, and move cli tests out of the way. (4 days ago) <Nick Martin>
| * | | b3bdb87 - async_multi: catch exceptions in expect, prevent multi-fail (4 days ago) <David Greenspan>

ls <?params...>

List files under source control, wires to git ls-files

panic

Lost, confused? Can't figure what state you are in? Use panic!

panic will checkout the latest stable state (HEAD) and remove all file not under source control, leaving a fresh clean workspace.

pull <?opts>

push <?opts>

  • deals with other branches

rb <?params...>

Rebases the branch, same as git rb

rm <params...>

Removes a file from source control, same as git rm

rs <params...>

Resets the branch to a different state. same as git reset

$ g rs upstream

remote <?params...>

Used to add/remove remotes, same as git remote

rv

Reverts a commit, same as git revert

setup

Configures user, key, editor, difftools by prompting the user.

st <?params...>

Propable the most used command: give details about what changed.

$ git st

submodule <?params...>

same as git submodule

sync

Synchronizes the current branch with the one of the server. syncs working branch: fetch, pull-rebase & push

tg

Tags a state, wires to git tag

track <?upstream_branch>

  • shows/set tracking
$ g track
local: master <--sync--> remote: origin/master
--Remotes---
origin	git@github.com:orefalo/g2.git (fetch)
origin	git@github.com:orefalo/g2.git (push)

pull

won't pull on a WIP won't pull from the tracking branch Will ask to setup tracking if not set

push

won't push a WIP won't push to the tracking branch Will ask to setup tracking if not set

unfreeze <?file>

  • freeze/unfreeze to staging area

unwip

Unstacks a WIP from the history into the workspace

wip

Easy way to save your WIP (Work In Progress). Stacks all current changes as a commit on the history.

##FAQ

###There is no stash ?

No, there is no stash. With commands wip and unwip, the stash brings little benefits. Since these commands create commits, it's also obvious to keep track of which branch they apply to.

###Is it a git replacement ?

g2 could be considered as a superset of git, in fact in still needs the git command to run.

###Is it a new git-flow ?

No, g2 doesn't enforce any branching policy.

###Why "g2" ?

g is the command
2 because most of the actions are two letters long.

###I am a GIT guru!

First, thanks for reading that far! As a git master you probably won't find much in g2. However should you like some of the commands, g2 is backed by git aliases and it should be pretty easy grab the few commands you like.

###What if my favorite command is mssing?

aliases are on the todo list. for now, you may run your command via $GIT_EXE

##Credits

Author: Olivier Refalo

Contains a modified version of git-prompt - Leonid Volnitsky
Contains a modified version of git-completion.bash - Shawn O. Pearce GUM by saintsjd. Wonder why this project feel short on delivery.

##License

Distributed under the GNU General Public License, version 2.0.

##TODO

  • g al
  • g hp
  • g hi back
  • g hi forward
  • g hi last
  • g rb -i should check if hash is local and warn
  • g am/rb add -f flag to bypass validation