6. Partial changes to the staging file In general, it is good practice to create an attribute-based commit, meaning that each commit must represent the creation of a new feature or a bug fix. What if you fixed two bugs, or added multiple new features but didn't commit the changes? In this case, you can put these changes in one commit. But a better approach would be to put the file on hold (stage) and submit it separately. For example, you have made several changes to a file and want to submit them separately. In this case, you can add the-p parameter to the add command ?
Let's demonstrate that 3 lines of text are added to the file_name file, but only the first and third lines are submitted. First look at the results of the Git diff display: And then see what is the Add-p parameter in the add command? It seems that Git assumes that all changes are directed at the same thing, so it puts them in a single block. You have several options as follows:
Enter Y to temporarily save the block
Input n is not staged
Enter E to edit the block manually
Enter D to exit or go to the next file
Enter S to split the block
In our example, we end up with the desire to split into smaller parts, and then selectively add or omit portions of them. As you can see, we added the first and third rows and ignored the second line. After that you can view the status of the warehouse and submit it. |