I doubt there's a single command to run. You're going to need a combination of tools running in sequence here.
Git includes an argument to list all files inside the repo: git ls-files
If you want to list only the untracked and modified files, you can use the -o
and -m
arguments:
git ls-files -o -m
If you pipeline that into a PowerShell function, it'll come in as an array, and you can iterate over all those files and do whatever you want with them. (I don't know SVN well, but presumably there should be a similar command there.)
Here is a script file which looks for a .git
file in your current working directory, calls git ls-files -o -m
, and pipes that output to another function that goes through each file and prints its full path. You could copy or move or whatever you wanted with each file:
function DoSomethingForGitLsFiles {
param(
[array]$FileList
)
Write-Host $FileList.count 'files found:'
foreach ($FilePath in $FileList)
{
# This is where you could copy your files out somewhere else.
Write-Host "FILE: $(Get-Location)\$FilePath"
}
}
function FindGitRepo {
param(
[string]$searchPath
)
if (Get-ChildItem -Name -Path "$searchPath\*.git") {
DoSomethingForGitLsFiles (git ls-files -o -m)
} else {
Write-Host "No .git repo found."
}
}
FindGitRepo -SearchPath (Get-Location)
Once your files are in a separate location, you could easily run 7-zip on the folder, etc...
That said, it sounds like what you might want instead is either a branch with just the needed changes which you could cherry-pick atop any other changeset, or perhaps a stash that you could reapply atop a changeset and then revert at-will.
https://git-scm.com/docs/git-stash
(Depending on your use case, stash may not quite be enough, but it's less well-known, so maybe it'll be useful.)