How to use SVN-commit in powershell
Svn works the same way in PowerShell as it does in a Command Prompt. If you define a variable with the full path to the executable you need to run it via the call operator (&
), though, because otherwise PowerShell would simply echo the string and be confused about the rest of the commandline.
$svn = 'C:\Program Files\TortoiseSVN\bin\svn.exe'
$myFile = 'C:\xx\file.txt'
$commitMsg = 'C:\xx\msg.txt'
& $svn commit -F $commitMsg $myFile
If you add the Svn directory to your path environment variable you can just invoke the executable directly:
$env:PATH += ';C:\Program Files\TortoiseSVN\bin'
...
svn.exe commit -F $commitMsg $myFile
Another option would be to define an alias for the executable:
New-Alias -Name svn -Value 'C:\Program Files\TortoiseSVN\bin\svn.exe'
...
svn commit -F $commitMsg $myFile
tommy2479
Updated on June 04, 2022Comments
-
tommy2479 almost 2 years
I would like to use SVN commands in my PowerShell script.
I know I need to declare the SVN executable as a variable, but afterwards I want to commit a file which I have declared as a variable and the commit message I would like to give is specified in a file.
$svnExe = "C:\Program Files\TortoiseSVN\bin\svn.exe" $myFile = "C:\xx\file.txt" $commitMsg = "C:\xx\msg.txt"
$myFile
is already a versioned file,$commitMsg
is not and will also not be a versioned file.From command-line this works:
svn commit -F C:\xx\msg.txt C:\xx\file.txt
But how would I do this using PowerShell?
-
tommy2479 about 7 yearsI tried the first suggestion you made. And find out that it need to be: $svnExe = 'C:\Program Files\TortoiseSVN\bin\svn.exe' $myFile = 'C:\xx\file.txt' $commitMsg = 'C:\xx\msg.txt' & $svnExe commit -F $commitMsg $myFile But afterwards I got the following problem: svn: E205008: Log message contains a zero byte At line:6 char:2 + & <<<< $svnExe commit -F $commitMsg $myFile + CategoryInfo : NotSpecified: (svn: E205008: L...ins a zero byte:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError
-
tommy2479 about 7 yearsAny idea how I solve the <svn: E205008: Log message contains a zero byte> issue?
-
Ansgar Wiechers about 7 years@tommy2479 You saved
msg.txt
in Unicode format. Save the file in ANSI format and the error will disappear. -
tommy2479 about 7 yearsthis really helped me out thnx!