There are two options when generating a patch from uncommitted changes: git diff and git diff --cached. git diff captures unstaged changes, modifications in the working directory that have not been added to the index. While git diff --cached captures staged changes that have been added to the index with git add but not yet committed. When creating a patch, git diff > file.patch will save only unstaged changes, whereas git diff --cached > file.patch will save only staged changes. Later, you can apply these patches using git apply file.patch to restore the changes in another working directory.
Source code viewer
# Option 1: Create a patch from UNSTAGED changes (modifications not yet added with git add) git diff > unstaged_changes.patch # Option 2: Create a patch from STAGED (CACHED) changes (modifications added with git add but not yet committed) git diff --cached > staged_changes.patch # OR git diff --staged > staged_changes.patchProgramming Language: Bash