How can I stage specific lines of file to git in NetBeans?

git, netbeans, netbeans-7, netbeans-plugins

Solution

Using `git add -p` is not a workaround but the way to do it.

If you need it more comfortable, fire up `git gui` as External Tool out of NetBeans and use it to stage lines manually.

Regardless if you get that working somehow or not: this is exactly the reason why I advocate using one tool for one task and not trying to do everything in one.

In Does netbeans ignore my git pre-commit hook?, I discussed that the Git implementation of NetBeans is far from being complete. `git add -p` does not seem being contained in the NetBeans Git integration plan.

NetBeans is using `jgit`. `jgit` does not provide means to stage parts of files, there's only the `AddCommand` that provides `addFilepattern()`. So the answer to your question is no, it won't work.

Problem

I'm quite new to using NetBeans and today I faced a problem. I have used to stage only part of files to make better commits. I have used vim and fugitive plug-in, where I can just move specific lines from unstaged to staged. I can do a workaround by calling git add -p, but it would be nice to do it straight from NetBeans IDE. Is there a mysterious way to do it simple by clicking somewhere and stage specific line(s)?

Original source

Related problems