Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)?

like image 752
samitheberber Avatar asked Aug 10 '12 09:08

samitheberber


People also ask

How do you commit changes in NetBeans?

Committing Sources to a Repository To commit files to the Git repository: In the Projects window, right-click the file(s) you want to commit. In the context menu, choose Git > Commit .

Is Git only single person can work on a file at one time?

Multiple please can work on the same file in GIT, it just has to be merged by the second person making a commit or push of the code.


1 Answers

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.

like image 139
eckes Avatar answered Oct 12 '22 22:10

eckes