mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-03-25 13:36:39 +01:00
Update configure-git.ps1
This commit is contained in:
parent
1e74c2d15f
commit
72a5fe04f5
@ -1,6 +1,6 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Configures the user settings for Git
|
||||
Configures Git
|
||||
.DESCRIPTION
|
||||
This PowerShell script configures the user settings for Git.
|
||||
.PARAMETER FullName
|
||||
@ -14,7 +14,7 @@
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz / License: CC0
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
param([string]$FullName = "", [string]$EmailAddress = "", [string]$FavoriteEditor = "")
|
||||
@ -24,11 +24,12 @@ try {
|
||||
if ($EmailAddress -eq "") { $EmailAddress = read-host "Enter your e-mail address"}
|
||||
if ($FavoriteEditor -eq "") { $FavoriteEditor = read-host "Enter your favorite text editor (emacs,nano,vi,vim,...)" }
|
||||
|
||||
"👉 Searching for Git executable... [step 1/3]"
|
||||
$StopWatch = [system.diagnostics.stopwatch]::startNew()
|
||||
"⏳ Step 1/3: Searching for Git executable..."
|
||||
& git --version
|
||||
if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" }
|
||||
|
||||
"👉 Configuring basic settings... [step 2/3]"
|
||||
"⏳ Step 2/3: Configuring basic settings..."
|
||||
& git config --global user.name $FullName
|
||||
& git config --global user.email $EmailAddress
|
||||
& git config --global core.editor $FavoriteEditor
|
||||
@ -39,9 +40,9 @@ try {
|
||||
& git config --global init.defaultBranch main
|
||||
& git config --global merge.renamelimit 99999
|
||||
& git config --global pull.rebase false
|
||||
if ($lastExitCode -ne "0") { throw "'git config' failed" }
|
||||
if ($lastExitCode -ne "0") { throw "'git config' failed with exit code $lastExitCode" }
|
||||
|
||||
"👉 Adding basic shortcuts (git st, git ls, etc.)... [step 3/3]"
|
||||
"⏳ Step 3/3: Adding basic shortcuts (git st, git ls, etc.)..."
|
||||
& git config --global alias.co "checkout"
|
||||
& git config --global alias.br "branch"
|
||||
& git config --global alias.ci "commit"
|
||||
@ -54,11 +55,13 @@ try {
|
||||
& git config --global alias.smu "submodule update --init"
|
||||
if ($lastExitCode -ne "0") { throw "'git config' failed" }
|
||||
|
||||
"✔️ saved your Git configuration, it's now:"
|
||||
[int]$Elapsed = $StopWatch.Elapsed.TotalSeconds
|
||||
"✔️ saved your personal Git configuration in $Elapsed sec, it's now:"
|
||||
|
||||
& git config --list
|
||||
if ($lastExitCode -ne "0") { throw "'git config --list' failed" }
|
||||
if ($lastExitCode -ne "0") { throw "'git config --list' failed with exit code $lastExitCode" }
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber)): $($Error[0])"
|
||||
exit 1
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user