Why won’t git add -p work on untracked file

Today I started writing a simple app for fun and decided I want it in source control.

One git init later I wanted to split what was so far written into more than one commit.

git add -p however said “no changes”.

After some trials and no successes, I turned to manual for add subcommand, and yes, there it was:

-p, –patch
Interactively choose hunks of patch between the index and the work
tree and add them to the index. This gives the user a chance to
review the difference before adding modified contents to the index.

BETWEEN THE INDEX and the work tree… so, without index, I’m doomed. That means, I can’t use add interactive on an untracked file.

Well, that’s that. For those who think now “just run git add -i“, it’s the same. Next paragraph in the manual states:

This effectively runs add –interactive, but bypasses the initial
command menu and directly jumps to the patch subcommand. See
“Interactive mode” for details.

Finally, if you think that interactive adding has option to add untracked files, that is true, but it adds them in their entirety.

So, no cookie, time for manual edits. 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s