Skip to content

Commit 9b1f517

Browse files
dschodscho
authored andcommitted
book: update sv
Updated via the `update-book.yml` GitHub workflow.
1 parent 4bd4ba9 commit 9b1f517

File tree

908 files changed

+28724
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

908 files changed

+28724
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
### DO NOT EDIT! Generated by script/update-book2.rb
3+
redirect_to: book/sv/v2
4+
---
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
### DO NOT EDIT! Generated by script/update-book2.rb
3+
category: book
4+
section: documentation
5+
subsection: book
6+
sidebar: book
7+
book:
8+
language_code: sv
9+
chapter:
10+
title: 'Bilaga A: Git in Other Environments'
11+
number: 1
12+
section:
13+
title: Git in Bash
14+
number: 4
15+
cs_number: A1.4
16+
previous: book/sv/v2/Bilaga-A:-Git-in-Other-Environments-Git-in-Eclipse
17+
next: book/sv/v2/Bilaga-A:-Git-in-Other-Environments-Git-in-Zsh
18+
title: Git - Git in Bash
19+
url: "/book/sv/v2/Bilaga-A:-Git-in-Other-Environments-Git-in-Bash.html"
20+
---
21+
<h2 id="_git_in_bash">Git in Bash</h2>
22+
<div class="paragraph">
23+
<p>
24+
If you’re a Bash user, you can tap into some of your shell’s features to make your experience with Git a lot friendlier.
25+
Git actually ships with plugins for several shells, but it’s not turned on by default.</p>
26+
</div>
27+
<div class="paragraph">
28+
<p>First, you need to get a copy of the <code>contrib/completion/git-completion.bash</code> file out of the Git source code.
29+
Copy it somewhere handy, like your home directory, and add this to your <code>.bashrc</code>:</p>
30+
</div>
31+
<div class="listingblock">
32+
<div class="content">
33+
<pre class="highlight"><code class="language-console" data-lang="console">. ~/git-completion.bash</code></pre>
34+
</div>
35+
</div>
36+
<div class="paragraph">
37+
<p>Once that’s done, change your directory to a Git repository, and type:</p>
38+
</div>
39+
<div class="listingblock">
40+
<div class="content">
41+
<pre class="highlight"><code class="language-console" data-lang="console">$ git chec&lt;tab&gt;</code></pre>
42+
</div>
43+
</div>
44+
<div class="paragraph">
45+
<p>…and Bash will auto-complete to <code>git checkout</code>.
46+
This works with all of Git’s subcommands, command-line parameters, and remotes and ref names where appropriate.</p>
47+
</div>
48+
<div class="paragraph">
49+
<p>It’s also useful to customize your prompt to show information about the current directory’s Git repository.
50+
This can be as simple or complex as you want, but there are generally a few key pieces of information that most people want, like the current branch, and the status of the working directory.
51+
To add these to your prompt, just copy the <code>contrib/completion/git-prompt.sh</code> file from Git’s source repository to your home directory, add something like this to your <code>.bashrc</code>:</p>
52+
</div>
53+
<div class="listingblock">
54+
<div class="content">
55+
<pre class="highlight"><code class="language-console" data-lang="console">. ~/git-prompt.sh
56+
export GIT_PS1_SHOWDIRTYSTATE=1
57+
export PS1='\w$(__git_ps1 " (%s)")\$ '</code></pre>
58+
</div>
59+
</div>
60+
<div class="paragraph">
61+
<p>The <code>\w</code> means print the current working directory, the <code>\$</code> prints the <code>$</code> part of the prompt, and <code>__git_ps1 " (%s)"</code> calls the function provided by <code>git-prompt.sh</code> with a formatting argument.
62+
Now your bash prompt will look like this when you’re anywhere inside a Git-controlled project:</p>
63+
</div>
64+
<div class="imageblock">
65+
<div class="content">
66+
<img src="{{< relurl "book/sv/v2/images/git-bash.png" >}}" alt="Customized `bash` prompt.">
67+
</div>
68+
<div class="title">Figur 162. Customized <code>bash</code> prompt.</div>
69+
</div>
70+
<div class="paragraph">
71+
<p>Both of these scripts come with helpful documentation; take a look at the contents of <code>git-completion.bash</code> and <code>git-prompt.sh</code> for more information.</p>
72+
</div>
73+
<div id="nav"><a href="{{< previous-section >}}">prev</a> | <a href="{{< next-section >}}">next</a></div>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
### DO NOT EDIT! Generated by script/update-book2.rb
3+
category: book
4+
section: documentation
5+
subsection: book
6+
sidebar: book
7+
book:
8+
language_code: sv
9+
chapter:
10+
title: 'Bilaga A: Git in Other Environments'
11+
number: 1
12+
section:
13+
title: Git in Eclipse
14+
number: 3
15+
cs_number: A1.3
16+
previous: book/sv/v2/Bilaga-A:-Git-in-Other-Environments-Git-in-Visual-Studio
17+
next: book/sv/v2/Bilaga-A:-Git-in-Other-Environments-Git-in-Bash
18+
title: Git - Git in Eclipse
19+
url: "/book/sv/v2/Bilaga-A:-Git-in-Other-Environments-Git-in-Eclipse.html"
20+
---
21+
<h2 id="_git_in_eclipse">Git in Eclipse</h2>
22+
<div class="paragraph">
23+
<p>
24+
Eclipse ships with a plugin called Egit, which provides a fairly-complete interface to Git operations.
25+
It’s accessed by switching to the Git Perspective (Window &gt; Open Perspective &gt; Other…, and select "Git").</p>
26+
</div>
27+
<div class="imageblock">
28+
<div class="content">
29+
<img src="{{< relurl "book/sv/v2/images/egit.png" >}}" alt="Eclipse’s EGit environment.">
30+
</div>
31+
<div class="title">Figur 161. Eclipse’s EGit environment.</div>
32+
</div>
33+
<div class="paragraph">
34+
<p>EGit comes with plenty of great documentation, which you can find by going to Help &gt; Help Contents, and choosing the "EGit Documentation" node from the contents listing.</p>
35+
</div>
36+
<div id="nav"><a href="{{< previous-section >}}">prev</a> | <a href="{{< next-section >}}">next</a></div>
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
### DO NOT EDIT! Generated by script/update-book2.rb
3+
category: book
4+
section: documentation
5+
subsection: book
6+
sidebar: book
7+
book:
8+
language_code: sv
9+
chapter:
10+
title: 'Bilaga A: Git in Other Environments'
11+
number: 1
12+
section:
13+
title: Git in PowerShell
14+
number: 6
15+
cs_number: A1.6
16+
previous: book/sv/v2/Bilaga-A:-Git-in-Other-Environments-Git-in-Zsh
17+
next: book/sv/v2/Bilaga-A:-Git-in-Other-Environments-Summary
18+
title: Git - Git in PowerShell
19+
url: "/book/sv/v2/Bilaga-A:-Git-in-Other-Environments-Git-in-PowerShell.html"
20+
---
21+
<h2 id="_git_powershell">Git in PowerShell</h2>
22+
<div class="paragraph">
23+
<p>
24+
25+
The legacy command-line terminal on Windows (<code>cmd.exe</code>) isn’t really capable of a customized Git experience, but if you’re using PowerShell, you’re in luck.
26+
This also works if you’re running PowerShell on a non-Windows platform like Debian.
27+
A package called Posh-Git (<a href="https://github.com/dahlbyk/posh-git" class="bare">https://github.com/dahlbyk/posh-git</a>) provides powerful tab-completion facilities, as well as an enhanced prompt to help you stay on top of your repository status.
28+
It looks like this:</p>
29+
</div>
30+
<div class="imageblock">
31+
<div class="content">
32+
<img src="{{< relurl "book/sv/v2/images/posh-git.png" >}}" alt="PowerShell with Posh-git.">
33+
</div>
34+
<div class="title">Figur 165. PowerShell with Posh-git.</div>
35+
</div>
36+
<div class="sect3">
37+
<h3 id="_installation_3">Installation</h3>
38+
<div class="sect4">
39+
<h4 id="_prerequisites_windows_only">Prerequisites (Windows only)</h4>
40+
<div class="paragraph">
41+
<p>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.
42+
If you’re an administrator and want to set it for all Users on that machine, use "-Scope LocalMachine".
43+
If you’re a normal user, without administrative rights, you can use "-Scope CurrentUser" to set it only for you.</p>
44+
</div>
45+
<div class="paragraph">
46+
<p>More about PowerShell Scopes: <a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scopes" class="bare">https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scopes</a></p>
47+
</div>
48+
<div class="paragraph">
49+
<p>More about PowerShell ExecutionPolicy: <a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy" class="bare">https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy</a></p>
50+
</div>
51+
<div class="listingblock">
52+
<div class="content">
53+
<pre class="highlight"><code class="language-powershell" data-lang="powershell">&gt; Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy RemoteSigned -Force</code></pre>
54+
</div>
55+
</div>
56+
</div>
57+
<div class="sect4">
58+
<h4 id="_powershell_gallery">PowerShell Gallery</h4>
59+
<div class="paragraph">
60+
<p>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.</p>
61+
</div>
62+
<div class="paragraph">
63+
<p>More information about PowerShell Gallery: <a href="https://docs.microsoft.com/en-us/powershell/gallery/overview" class="bare">https://docs.microsoft.com/en-us/powershell/gallery/overview</a></p>
64+
</div>
65+
<div class="listingblock">
66+
<div class="content">
67+
<pre class="highlight"><code class="language-powershell" data-lang="powershell">&gt; Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
68+
&gt; Update-Module PowerShellGet -Force
69+
&gt; Install-Module Posh-Git -Scope AllUsers</code></pre>
70+
</div>
71+
</div>
72+
<div class="paragraph">
73+
<p>If you want to install Posh-Git only for the current user and not globally, use "-Scope CurrentUser" instead.
74+
If the second command fails with an error like <code>Module 'PowerShellGet' was not installed by using Install-Module</code>, you’ll need to run another command first:</p>
75+
</div>
76+
<div class="listingblock">
77+
<div class="content">
78+
<pre class="highlight"><code class="language-powershell" data-lang="powershell">&gt; Install-Module PowerShellGet -Force -SkipPublisherCheck</code></pre>
79+
</div>
80+
</div>
81+
<div class="paragraph">
82+
<p>Then you can go back and try again.
83+
This happens, because the modules that ship with Windows PowerShell are signed with a different publishment certificate.</p>
84+
</div>
85+
</div>
86+
<div class="sect4">
87+
<h4 id="_update_powershell_prompt">Update PowerShell Prompt</h4>
88+
<div class="paragraph">
89+
<p>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.
90+
Keep in mind, that there are multiple $profile scripts. E. g. one for the console and a separate one for the ISE.</p>
91+
</div>
92+
<div class="listingblock">
93+
<div class="content">
94+
<pre class="highlight"><code class="language-powershell" data-lang="powershell">&gt; New-Item -Name $(Split-Path -Path $profile) -ItemType Directory -Force
95+
&gt; 'Import-Module Posh-Git' | Out-File -Append -Encoding default -FilePath $profile</code></pre>
96+
</div>
97+
</div>
98+
</div>
99+
<div class="sect4">
100+
<h4 id="_from_source">From Source</h4>
101+
<div class="paragraph">
102+
<p>Just download a Posh-Git release from (<a href="https://github.com/dahlbyk/posh-git" class="bare">https://github.com/dahlbyk/posh-git</a>), and uncompress it to the <code>WindowsPowerShell</code> directory.
103+
Then open a PowerShell prompt as an administrator, and do this:</p>
104+
</div>
105+
<div class="listingblock">
106+
<div class="content">
107+
<pre class="highlight"><code class="language-powershell" data-lang="powershell">&gt; cd ~\Documents\WindowsPowerShell\Module\posh-git
108+
&gt; .\install.ps1</code></pre>
109+
</div>
110+
</div>
111+
<div class="paragraph">
112+
<p>This will add the proper line to your <code>profile.ps1</code> file, and posh-git will be active the next time you open your prompt.</p>
113+
</div>
114+
</div>
115+
</div>
116+
<div id="nav"><a href="{{< previous-section >}}">prev</a> | <a href="{{< next-section >}}">next</a></div>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
### DO NOT EDIT! Generated by script/update-book2.rb
3+
category: book
4+
section: documentation
5+
subsection: book
6+
sidebar: book
7+
book:
8+
language_code: sv
9+
chapter:
10+
title: 'Bilaga A: Git in Other Environments'
11+
number: 1
12+
section:
13+
title: Git in Visual Studio
14+
number: 2
15+
cs_number: A1.2
16+
previous: book/sv/v2/Bilaga-A:-Git-in-Other-Environments-Graphical-Interfaces
17+
next: book/sv/v2/Bilaga-A:-Git-in-Other-Environments-Git-in-Eclipse
18+
title: Git - Git in Visual Studio
19+
url: "/book/sv/v2/Bilaga-A:-Git-in-Other-Environments-Git-in-Visual-Studio.html"
20+
---
21+
<h2 id="_git_in_visual_studio">Git in Visual Studio</h2>
22+
<div class="paragraph">
23+
<p>
24+
Starting with Visual Studio 2013 Update 1, Visual Studio users have a Git client built directly into their IDE.
25+
Visual Studio has had source-control integration features for quite some time, but they were oriented towards centralized, file-locking systems, and Git was not a good match for this workflow.
26+
Visual Studio 2013’s Git support has been separated from this older feature, and the result is a much better fit between Studio and Git.</p>
27+
</div>
28+
<div class="paragraph">
29+
<p>To locate the feature, open a project that’s controlled by Git (or just <code>git init</code> an existing project), and select View &gt; Team Explorer from the menu.
30+
You’ll see the "Connect" view, which looks a bit like this:</p>
31+
</div>
32+
<div class="imageblock">
33+
<div class="content">
34+
<img src="{{< relurl "book/sv/v2/images/vs-1.png" >}}" alt="Connecting to a Git repository from Team Explorer.">
35+
</div>
36+
<div class="title">Figur 159. Connecting to a Git repository from Team Explorer.</div>
37+
</div>
38+
<div class="paragraph">
39+
<p>Visual Studio remembers all of the projects you’ve opened that are Git-controlled, and they’re available in the list at the bottom.
40+
If you don’t see the one you want there, click the "Add" link and type in the path to the working directory.
41+
Double clicking on one of the local Git repositories leads you to the Home view, which looks like <a href="{{< relurl "book/sv/v2/ch00/vs_home" >}}">The "Home" view for a Git repository in Visual Studio.</a>.
42+
This is a hub for performing Git actions; when you’re <em>writing</em> code, you’ll probably spend most of your time in the "Changes" view, but when it comes time to pull down changes made by your teammates, you’ll use the "Unsynced Commits" and "Branches" views.</p>
43+
</div>
44+
<div id="vs_home" class="imageblock">
45+
<div class="content">
46+
<img src="{{< relurl "book/sv/v2/images/vs-2.png" >}}" alt="The Home view for a Git repository in Visual Studio.">
47+
</div>
48+
<div class="title">Figur 160. The "Home" view for a Git repository in Visual Studio.</div>
49+
</div>
50+
<div class="paragraph">
51+
<p>Visual Studio now has a powerful task-focused UI for Git.
52+
It includes a linear history view, a diff viewer, remote commands, and many other capabilities.
53+
For complete documentation of this feature (which doesn’t fit here), go to <a href="http://msdn.microsoft.com/en-us/library/hh850437.aspx" class="bare">http://msdn.microsoft.com/en-us/library/hh850437.aspx</a>.</p>
54+
</div>
55+
<div id="nav"><a href="{{< previous-section >}}">prev</a> | <a href="{{< next-section >}}">next</a></div>
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
### DO NOT EDIT! Generated by script/update-book2.rb
3+
category: book
4+
section: documentation
5+
subsection: book
6+
sidebar: book
7+
book:
8+
language_code: sv
9+
chapter:
10+
title: 'Bilaga A: Git in Other Environments'
11+
number: 1
12+
section:
13+
title: Git in Zsh
14+
number: 5
15+
cs_number: A1.5
16+
previous: book/sv/v2/Bilaga-A:-Git-in-Other-Environments-Git-in-Bash
17+
next: book/sv/v2/Bilaga-A:-Git-in-Other-Environments-Git-in-PowerShell
18+
title: Git - Git in Zsh
19+
url: "/book/sv/v2/Bilaga-A:-Git-in-Other-Environments-Git-in-Zsh.html"
20+
---
21+
<h2 id="_git_in_zsh">Git in Zsh</h2>
22+
<div class="paragraph">
23+
<p>
24+
Zsh also ships with a tab-completion library for Git.
25+
To use it, simply run <code>autoload -Uz compinit &amp;&amp; compinit</code> in your <code>.zshrc</code>.
26+
Zsh’s interface is a bit more powerful than Bash’s:</p>
27+
</div>
28+
<div class="listingblock">
29+
<div class="content">
30+
<pre class="highlight"><code class="language-console" data-lang="console">$ git che&lt;tab&gt;
31+
check-attr -- display gitattributes information
32+
check-ref-format -- ensure that a reference name is well formed
33+
checkout -- checkout branch or paths to working tree
34+
checkout-index -- copy files from index to working directory
35+
cherry -- find commits not merged upstream
36+
cherry-pick -- apply changes introduced by some existing commits</code></pre>
37+
</div>
38+
</div>
39+
<div class="paragraph">
40+
<p>Ambiguous tab-completions aren’t just listed; they have helpful descriptions, and you can graphically navigate the list by repeatedly hitting tab.
41+
This works with Git commands, their arguments, and names of things inside the repository (like refs and remotes), as well as filenames and all the other things Zsh knows how to tab-complete.</p>
42+
</div>
43+
<div class="paragraph">
44+
<p>Zsh ships with a framework for getting information from version control systems, called <code>vcs_info</code>.
45+
To include the branch name in the prompt on the right side, add these lines to your <code>~/.zshrc</code> file:</p>
46+
</div>
47+
<div class="listingblock">
48+
<div class="content">
49+
<pre class="highlight"><code class="language-console" data-lang="console">autoload -Uz vcs_info
50+
precmd_vcs_info() { vcs_info }
51+
precmd_functions+=( precmd_vcs_info )
52+
setopt prompt_subst
53+
RPROMPT=\$vcs_info_msg_0_
54+
# PROMPT=\$vcs_info_msg_0_'%# '
55+
zstyle ':vcs_info:git:*' formats '%b'</code></pre>
56+
</div>
57+
</div>
58+
<div class="paragraph">
59+
<p>This results in a display of the current branch on the right-hand side of the terminal window, whenever your shell is inside a Git repository.
60+
(The left side is supported as well, of course; just uncomment the assignment to PROMPT.)
61+
It looks a bit like this:</p>
62+
</div>
63+
<div class="imageblock">
64+
<div class="content">
65+
<img src="{{< relurl "book/sv/v2/images/zsh-prompt.png" >}}" alt="Customized `zsh` prompt.">
66+
</div>
67+
<div class="title">Figur 163. Customized <code>zsh</code> prompt.</div>
68+
</div>
69+
<div class="paragraph">
70+
<p>For more information on vcs_info, check out its documentation
71+
in the <code>zshcontrib(1)</code> manual page,
72+
or online at <a href="http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#Version-Control-Information" class="bare">http://zsh.sourceforge.net/Doc/Release/User-Contributions.html#Version-Control-Information</a>.</p>
73+
</div>
74+
<div class="paragraph">
75+
<p>Instead of vcs_info, you might prefer the prompt customization script that ships with Git, called <code>git-prompt.sh</code>; see <a href="https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh" class="bare">https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh</a> for details.
76+
<code>git-prompt.sh</code> is compatible with both Bash and Zsh.</p>
77+
</div>
78+
<div class="paragraph">
79+
<p>Zsh is powerful enough that there are entire frameworks dedicated to making it better.
80+
One of them is called "oh-my-zsh", and it can be found at <a href="https://github.com/robbyrussell/oh-my-zsh" class="bare">https://github.com/robbyrussell/oh-my-zsh</a>.
81+
oh-my-zsh’s plugin system comes with powerful git tab-completion, and it has a variety of prompt "themes", many of which display version-control data.
82+
<a href="{{< relurl "book/sv/v2/ch00/oh_my_zsh_git" >}}">An example of an oh-my-zsh theme.</a> is just one example of what can be done with this system.</p>
83+
</div>
84+
<div id="oh_my_zsh_git" class="imageblock">
85+
<div class="content">
86+
<img src="{{< relurl "book/sv/v2/images/zsh-oh-my.png" >}}" alt="An example of an oh-my-zsh theme.">
87+
</div>
88+
<div class="title">Figur 164. An example of an oh-my-zsh theme.</div>
89+
</div>
90+
<div id="nav"><a href="{{< previous-section >}}">prev</a> | <a href="{{< next-section >}}">next</a></div>

0 commit comments

Comments
 (0)