What Do Double Dashes (--) After the "git stash" Command Do?

In Git, when you use the git stash command, you can specify a double dash (--) option followed by a list of files or paths. The double dashes are used to separate Git's own options and arguments from the file paths or patterns you want to stash.

For example, if you have changes in your working directory, and you want to stash only specific files, then you can use the double dashes (--) followed by the file paths you want to stash:

git stash -- path/to/file1 path/to/file2

This will stash only the changes in "file1" and "file2", leaving other changes in your working directory untouched.

Please note that the double dash (--) is not a part of the git stash command itself but rather a general Git syntax used to separate command options from file paths or other arguments.


This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.