Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Commit specific lines of a file to git [duplicate]

Tags:

git

Possible Duplicate:
How can I commit only part of a file in git

How do I commit a few specific line ranges from a file to git? while ignoring some other line changes in the same file.

like image 764
erikvold Avatar asked Nov 29 '10 23:11

erikvold


People also ask

How do I commit only part of a file?

In the Commit window, select the file you want to partially commit, then select the text you want to commit in the right pane, then right-click on the selection and choose 'Stage selected lines' from the context menu.

What command is used to stage only some changes in a file?

git add -p is basically "git add partial (or patch)" Patch mode allows you to stage parts of a changed file, instead of the entire file. This allows you to make concise, well-crafted commits that make for an easier to read history.

How do you add all changes not staged for commit?

The easiest way to add all files to your Git repository is to use the “git add” command followed by the “-A” option for “all”. In this case, the new (or untracked), deleted and modified files will be added to your Git staging area.


1 Answers

Try git add -p -- it will interactively let you add, skip, or split diff hunks.

like image 84
Adam DiCarlo Avatar answered Oct 04 '22 13:10

Adam DiCarlo