Skip to content

Commit 1a88b5d

Browse files
authored
Merge pull request progit#1046 from agowa338/agowa338-patch-1
Update for PowerShell 6 (Core) and Visual Studio Code
2 parents a5f188d + 083fdf6 commit 1a88b5d

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

book/A-git-in-other-environments/sections/guis.asc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ Then you can simply stage or unstage some changes, alter the commit message, and
6666
`gitk` and `git-gui` are examples of task-oriented tools.
6767
Each of them is tailored for a specific purpose (viewing history and creating commits, respectively), and omit the features not necessary for that task.
6868

69-
7069
==== GitHub for Mac and Windows
7170

7271
(((GitHub for Mac)))(((GitHub for Windows)))

book/A-git-in-other-environments/sections/powershell.asc

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33

44
(((powershell)))(((tab completion, powershell)))(((shell prompts, powershell)))
55
(((posh-git)))
6-
The standard command-line terminal on Windows (`cmd.exe`) isn't really capable of a customized Git experience, but if you're using Powershell, you're in luck.
6+
The legacy command-line terminal on Windows (`cmd.exe`) isn't really capable of a customized Git experience, but if you're using Powershell, you're in luck.
7+
This also works if you're running PowerShell on a non-Windows platform like Debian.
78
A package called Posh-Git (https://github.com/dahlbyk/posh-git[]) provides powerful tab-completion facilities, as well as an enhanced prompt to help you stay on top of your repository status.
89
It looks like this:
910

1011
.Powershell with Posh-git.
1112
image::images/posh-git.png[Powershell with Posh-git.]
1213

1314
==== Installation
14-
===== Prerequisites
15+
===== Prerequisites (Windows only)
1516
Before you're able to run PowerShell scripts on your machine, you need to set your local ExecutionPolicy to RemoteSigned (Basically anything except Undefined and Restricted). If you choose AllSigned instead of RemoteSigned, also local scripts (your own) need to be digitally signed in order to be executed. With RemoteSigned, only Scripts having the "ZoneIdentifier" set to Internet (were downloaded from the web) need to be signed, others not.
1617
If you're an administrator and want to set it for all Users on that machine, use "-Scope LocalMachine".
1718
If you're a normal user, without administrative rights, you can use "-Scope CurrentUser" to set it only for you.
@@ -28,16 +29,27 @@ If you have at least PowerShell 5 or PowerShell 4 with PackageManagement install
2829
More information about the requirements: (https://docs.microsoft.com/en-us/powershell/gallery/psget/get_psget_module[])
2930
[source,powershell]
3031
-----
32+
> Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
3133
> Update-Module PowerShellGet -Force
32-
> Install-Module Posh-Git -Scope LocalMachine
34+
> Install-Module Posh-Git -Scope AllUsers
3335
-----
34-
If you want to install Posh-Git only for the currnet user and not globaly, use "-Scope CurrentUser" instead.
36+
If you want to install Posh-Git only for the current user and not globally, use "-Scope CurrentUser" instead.
37+
If the second command fails with an error like `Module 'PowerShellGet' was not installed by using Install-Module`, you'll need to run another command first:
38+
39+
[source,powershell]
40+
----
41+
> Install-Module PowerShellGet -Force -SkipPublisherCheck
42+
----
43+
44+
Then you can go back and try again.
45+
This happens, because the modules that ship with Windows Powershell are signed with a different publishment certificate.
3546

3647
===== Update PowerShell Prompt
3748
To include git information in your prompt, posh-git needs to be imported. To do this automatically, include the import statement into you $profile script. This script is executed everytime you open a new PowerShell prompt.
3849
Keep in mind, that there are multiple $profile scripts. E. g. one for the console and a separate one for the ISE.
3950
[source,powershell]
4051
-----
52+
> New-Item -Name $(Split-Path -Path $profile) -ItemType Directory -Force
4153
> 'Import-Module Posh-Git' | Out-File -Append -Encoding default -FilePath $profile
4254
-----
4355

0 commit comments

Comments
 (0)