The easiest way is making your works in a subshell only:
snip-git() (
cd -- "$snippetdir"
git add .
git commit -m "."
git push -u
)
* * *
There're some thing you want to fix in your function:
* Remember to always quote your variables.
* You refer variable using `$cwd` instead of `cwd`.