At first sight Set-Location and Push-Location PowerShell cmdlets look alike when it comes to changing the current directory.
What are use cases for each? When would one choose to use one over the other?
They will both change the working directory but using Push-Location
will add the current working directory to the top of a stack before changing to the new working directory. You can then use Pop-Location
to traverse back down the stack through the previous working directories.
Set-Location
will just change the working directory in the same way that cd
would.
Set-Location = cd
Push-Location = pushd
Pop-Location = popd