The correct command to stash specific files (like your scripts/dags/dqm_slack_alert.py
file) is not directly supported through a simple Git command, but you can achieve this by specifying a patch and selectively adding files to it. Here’s how you can do it:
Start an Interactive Stash
git stash push -p
Select Changes to Stash:
Git will now show you each hunk of change in your files. For each hunk, you can decide whether to stash it or not:
- Type
y
(yes) to stash the changes in the hunk. - Type
n
(no) to keep the changes in the current branch. - Type
q
(quit) to exit the stash process without completing the stash.
You only select y
for the hunks in the scripts/dags/dqm_slack_alert.py
file.
Verify the Stash:
After you’ve gone through all your changes, you can check that your file is in the stash:
git stash list
git stash show -p stash@{0}
To stash changes for just one specific file (scripts/dags/alert.py) directly without going through an interactive selection process, you can use the following Git command:
git stash push -m "Stashing dqm_slack_alert.py" scripts/dags/alert.py
This command directly stashes the changes made to scripts/dags/alert.py and adds a message to the stash for easy identification. You can confirm the changes were stashed by listing your stashes:
git stash list
And to view the details of the stashed changes, use:
git stash show -p stash@{0} # Replace 0 with the appropriate stash index if needed