| Start |
|---|
Staging All Changes to Files In version 2.x, Use |
Unstage a file that contains changes |
| Add changes by hunk You can see what "hunks" of work would be staged for commit using the patch flag: or This opens an interactive prompt that allows you to look at the diffs and let you decide whether you want to include them or not.
This makes it easy to catch changes which you do not want to commit. You can also open this via |
| Interactive add
It is very useful (1) if you have entangled changes in the working directory that you want to put in separate commits, and not all in one single commit (2) if you are in the middle of an interactive rebase and want to split too large commit. The top half of this output shows the current state of the index broken up into staged and unstaged columns:
The bottom half shows what you can do. Either enter a number (1-8) or a letter (
|
| Show Staged Changes To display the hunks that are staged for commit: |
| Staging A Single File To stage a file for committing, run |
Stage deleted files To delete the file from git without removing it from disk, use the RemarksIt's worth noting that staging has little to do with 'files' themselves and everything to do with the changes within each given file. We stage files that contain changes, and git tracks the changes as commits (even when the changes in a commit are made across several files). The distinction between files and commits may seem minor, but understanding this difference is fundamental to understanding essential functions like cherry-pick and diff. (See the frustration in comments regarding the complexity of an accepted answer that proposes cherry-pick as a file management tool (opens new window).) What's a good place for explaining concepts? Is it in remarks? Key concepts: A files is the more common metaphor of the two in information technology. Best practice dictates that a filename not change as its contents change (with a few recognized exceptions). A commit is a metaphor that is unique to source code management. Commits are changes related to a specific effort, like a bug fix. Commits often involve several files. A single, minor bug fix may involve tweaks to templates and css in unique files. As the change is described, developed, documented, reviewed and deployed, the changes across the separate files can be annotated and handled as a single unit. The single unit in this case is the commit. Equally important, focusing just on the commit during a review allows the unchanged lines of code in the various affected files to be ignored safely. |
Staging All Changes to Files In version 2.x, Use |
Unstage a file that contains changes |
| Add changes by hunk You can see what "hunks" of work would be staged for commit using the patch flag: or This opens an interactive prompt that allows you to look at the diffs and let you decide whether you want to include them or not.
This makes it easy to catch changes which you do not want to commit. You can also open this via |
| Interactive add
It is very useful (1) if you have entangled changes in the working directory that you want to put in separate commits, and not all in one single commit (2) if you are in the middle of an interactive rebase and want to split too large commit. The top half of this output shows the current state of the index broken up into staged and unstaged columns:
The bottom half shows what you can do. Either enter a number (1-8) or a letter (
|
| Show Staged Changes To display the hunks that are staged for commit: |
| Staging A Single File To stage a file for committing, run |
Stage deleted files To delete the file from git without removing it from disk, use the RemarksIt's worth noting that staging has little to do with 'files' themselves and everything to do with the changes within each given file. We stage files that contain changes, and git tracks the changes as commits (even when the changes in a commit are made across several files). The distinction between files and commits may seem minor, but understanding this difference is fundamental to understanding essential functions like cherry-pick and diff. (See the frustration in comments regarding the complexity of an accepted answer that proposes cherry-pick as a file management tool (opens new window).) What's a good place for explaining concepts? Is it in remarks? Key concepts: A files is the more common metaphor of the two in information technology. Best practice dictates that a filename not change as its contents change (with a few recognized exceptions). A commit is a metaphor that is unique to source code management. Commits are changes related to a specific effort, like a bug fix. Commits often involve several files. A single, minor bug fix may involve tweaks to templates and css in unique files. As the change is described, developed, documented, reviewed and deployed, the changes across the separate files can be annotated and handled as a single unit. The single unit in this case is the commit. Equally important, focusing just on the commit during a review allows the unchanged lines of code in the various affected files to be ignored safely. |
Read Article
https://develop.horje.com/learn/1434/reference