Git 🌙
Chapters ▾ 2nd Edition

A1.6 Appendix A: Git in Other Environments - Git sa Powershell

Git sa Powershell

Ang standard na command-line terminal sa Windows (cmd.exe) ay hindi talaga kaya ng isang pinasadya na karanasan sa Git, ngunit kung gumagamit ka ng Powershell, ikaw ay swerte. Ang isang pakete na tinatawag na Posh-Git (https://github.com/dahlbyk/posh-git) ay nagbibigay ng malakas na mga pasilidad ng tab na pagkumpleto, pati na rin ang pinahusay na prompt upang matulungan kang manatili sa ibabaw ng iyong katayuan ng repositoryo. Mukhang ganito:

Powershell with Posh-git.
Figure 165. Powershell with Posh-git.

Pag-install

Mga kinakailangan

Bago mo magagawang patakbuhin ang mga script ng PowerShell sa iyong makina, kailangan mong itakda ang iyong lokal na ExecutionPolicy sa RemoteSigned (Karaniwang anumang bagay maliban sa Hindi tiyak at Ipinagbabawal). 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. If you’re an administrator and want to set it for all Users on that machine, use "-Scope LocalMachine". If you’re a normal user, without administrative rights, you can use "-Scope CurrentUser" to set it only for you. More about PowerShell Scopes: (https://technet.microsoft.com/de-de/library/hh847849.aspx) More about PowerShell ExecutionPolicy: (https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy)

> Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy RemoteSigned -Force

If you have at least PowerShell 5 or PowerShell 4 with PackageManagement installed, you can use the package manager to fetch Posh-Git for you. More information about the requirements: (https://docs.microsoft.com/en-us/powershell/gallery/psget/get_psget_module)

> Update-Module PowerShellGet -Force
> Install-Module Posh-Git -Scope LocalMachine

If you want to install Posh-Git only for the currnet user and not globaly, use "-Scope CurrentUser" instead.

Update PowerShell Prompt

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. Keep in mind, that there are multiple $profile scripts. E. g. one for the console and a separate one for the ISE.

> 'Import-Module Posh-Git' | Out-File -Append -Encoding default -FilePath $profile

From Source

Just download a Posh-Git release from (https://github.com/dahlbyk/posh-git), and uncompress it to the WindowsPowershell directory. Then open a Powershell prompt as an administrator, and do this:

> cd ~\Documents\WindowsPowerShell\Module\posh-git
> .\install.ps1

This will add the proper line to your profile.ps1 file, and posh-git will be active the next time you open your prompt.

scroll-to-top