Skip to content

Instantly share code, notes, and snippets.

@coleww
Last active August 29, 2015 14:02
Show Gist options
  • Save coleww/fe97ae1d280509109626 to your computer and use it in GitHub Desktop.
Save coleww/fe97ae1d280509109626 to your computer and use it in GitHub Desktop.
ga 1 33 7
# GIT THEORY
* git status is modified to append an index before each filename
cole@machine:~/PROJECTS/gtr-bf$ gs
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# 0 - TEST.MD
# 1 - TEST2.md
# 2 - TEST3.md
nothing added to commit but untracked files present (use "git add" to track)
* git add modified to accept indices in place of filenames
cole@machine:~/PROJECTS/gtr-bf$ ga 0 2
cole@machine:~/PROJECTS/gtr-bf$ gs
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: 0 - TEST.MD
# new file: 2 - TEST3.md
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# 1 - TEST2.md
* Most of the time we're adding one file or all of them.
The indices become particularly useful when, for example,
working on a feature that touches a lot of files
or perhaps with refinery extensions which end up
having extremely long path names.
cole@machine:~/PROJECTS/gtr-bf$ git reset
cole@machine:~/PROJECTS/gtr-bf$ gs
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# TEST.MD
# TEST2.md
# TEST3.md
nothing added to commit but untracked files present (use "git add" to track)
* Say, for example, you are working on a complex nested form
and so you put a debugging line in the rails controller that says something like
"raise params.to_s". After working on your haml scss and coffee files,
you go to commit and you want everything except the controller
which you only changed for debugging purposes. You could git add -A
and then git reset the controller, or you can do this:
cole@machine:~/PROJECTS/gtr-bf$ ga -1
cole@machine:~/PROJECTS/gtr-bf$ gs
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: 0 - TEST.MD
# new file: 2 - TEST3.md
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# 1 - TEST2.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment