0

In my git project I have a single unstaged file called init.rb.

I would like to split it and then add it. Or add it while splitting it. When I do

git add --interactive init.rb

I don't get the option to split my file into separate hunks. Or maybe I am misreading the options. How do I go ahead with this?

Amit Erandole
  • 11,995
  • 23
  • 65
  • 103

1 Answers1

2

If what you want is adding to the index part of the changes you made to init.rb while leaving other changes in work tree then you're looking for git add --patch init.rb. This option is available in interactive mode as well. It will split your changes in small parts and show them one by one allowing you to choose whether you want to add current one to index, leave it in work tree or split it in smaller parts.

See man page for more information.

KL-7
  • 46,000
  • 9
  • 87
  • 74