Tuesday, January 13, 2015

A little git trick

A little git trick I learned recently. For the safety mapping app, I am using a personal api token, which I would not want to show in Github. It turns out, it is possible to commit an entire file excluding the line you don't want to show (i.e., the api_token).

git add -i is a command that brings up an interactive window. From there, you want to choose #5 (patch), and git will walk you through the steps. When you are ready to stage, you are presented with several choices - 'y' for yes etc. One of the useful choices is 's' - split. For example, you might have 5 new lines, and only 4 of those you want to commit. Using -s command, one can split these lines into separate commits, and proceed as needed.

Actual details are available here.

No comments :

Post a Comment