Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Git's interactive mode has a patch action. This is the shortcut for it: git add --patch <file> It will split the file into hunks and interactively ask which one's to add. It has a plethor...
Answer
#2: Post edited
- Git's [interactive mode](https://git-scm.com/docs/git-add#_interactive_mode) has a [patch action](https://git-scm.com/docs/git-add#Documentation/git-add.txt---patch). This is the shortcut for it:
- ```bash
- git add --patch <file>
- ```
- It will split the file into hunks and interactively ask which one's to add. It has a plethora of options but selecting `?` explains them nicely:
```- <the hunk diff is shown here>
- (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? ?
- y - stage this hunk
- n - do not stage this hunk
- q - quit; do not stage this hunk or any of the remaining ones
- a - stage this hunk and all later hunks in the file
- d - do not stage this hunk or any of the later hunks in the file
- j - leave this hunk undecided, see next undecided hunk
- J - leave this hunk undecided, see next hunk
- g - select a hunk to go to
- / - search for a hunk matching the given regex
- e - manually edit the current hunk
- ? - print help
- ```
- The free [online git book](https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging) has a good explanation of this too.
- Git's [interactive mode](https://git-scm.com/docs/git-add#_interactive_mode) has a [patch action](https://git-scm.com/docs/git-add#Documentation/git-add.txt---patch). This is the shortcut for it:
- ```bash
- git add --patch <file>
- ```
- It will split the file into hunks and interactively ask which one's to add. It has a plethora of options but selecting `?` explains them nicely:
- ```txt
- <the hunk diff is shown here>
- (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? ?
- y - stage this hunk
- n - do not stage this hunk
- q - quit; do not stage this hunk or any of the remaining ones
- a - stage this hunk and all later hunks in the file
- d - do not stage this hunk or any of the later hunks in the file
- j - leave this hunk undecided, see next undecided hunk
- J - leave this hunk undecided, see next hunk
- g - select a hunk to go to
- / - search for a hunk matching the given regex
- e - manually edit the current hunk
- ? - print help
- ```
- The free [online git book](https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging) has a good explanation of this too.
#1: Initial revision
Git's [interactive mode](https://git-scm.com/docs/git-add#_interactive_mode) has a [patch action](https://git-scm.com/docs/git-add#Documentation/git-add.txt---patch). This is the shortcut for it: ```bash git add --patch <file> ``` It will split the file into hunks and interactively ask which one's to add. It has a plethora of options but selecting `?` explains them nicely: ``` <the hunk diff is shown here> (1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? ? y - stage this hunk n - do not stage this hunk q - quit; do not stage this hunk or any of the remaining ones a - stage this hunk and all later hunks in the file d - do not stage this hunk or any of the later hunks in the file j - leave this hunk undecided, see next undecided hunk J - leave this hunk undecided, see next hunk g - select a hunk to go to / - search for a hunk matching the given regex e - manually edit the current hunk ? - print help ``` The free [online git book](https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging) has a good explanation of this too.