Posts

Showing posts with the label stash

Advanced work with git stash

Advanced work with git stash In Git, the most recent stash is  always  assigned the index  0 , appearing as  stash@{0} . When you create a new stash, all existing stashes are pushed down the stack (e.g., the previous  0  becomes  1 ).   1. Identify which stash is yours To see all your stashed entries and their assigned numbers, use: git stash list   This will output a list like this: stash@{0}: WIP on master: 4fd1101...  (Latest) stash@{1}: On develop: updated files...   2. View contents without applying You can inspect the contents of any stash entry using the  show  command. View a file summary (stat): git stash show stash@{0} (Shows only the list of files changed and the number of insertions/deletions) View full code changes (diff): git stash show -p stash@{0} (The  -p  or  --patch  flag shows the actual line-by-line code changes) View untracked files: git stash show --include-untracked stash@{0} Vie...

Export Git Stash as patches

Export Git Stash as patches  git stash show -u -p --binary stash@{0} > your_changes_name.patch -u   - for untracked files -p - patch -binary - for binary files (images) stash@{0} - for fist stash (most fresh one) now you can transfer the  your_changes_name.patch  file to the target machine/repository (e.g., via email, USB drive, or cloud storage). In the target repository: Verify the patch  (optional):  git apply --check  your_changes_name.patch Apply the patch :  git apply  your_changes_name.patch . You may use  --ignore-whitespace  options if conflicts arise due to formatting differences. The changes will appear in your working directory as unstaged modifications