Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use Push-Location versus Set-Location?

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?

like image 487
jaccus Avatar asked Sep 23 '15 08:09

jaccus


1 Answers

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
like image 62
arco444 Avatar answered Sep 30 '22 16:09

arco444