Skip to content

Commit 916a8fd

Browse files
git-emsergiocabral
authored andcommitted
Update /book/A-git-in-other-enviroments/sections/
1 parent 71c52ff commit 916a8fd

9 files changed

Lines changed: 178 additions & 81 deletions

File tree

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ First, you need to get a copy of the `contrib/completion/git-completion.bash` fi
88
Copy it somewhere handy, like your home directory, and add this to your `.bashrc`:
99

1010
[source,console]
11-
-----
11+
----
1212
. ~/git-completion.bash
13-
-----
13+
----
1414

1515
Once that's done, change your directory to a Git repository, and type:
1616

@@ -27,16 +27,16 @@ This can be as simple or complex as you want, but there are generally a few key
2727
To add these to your prompt, just copy the `contrib/completion/git-prompt.sh` file from Git's source repository to your home directory, add something like this to your `.bashrc`:
2828

2929
[source,console]
30-
-----
30+
----
3131
. ~/git-prompt.sh
3232
export GIT_PS1_SHOWDIRTYSTATE=1
3333
export PS1='\w$(__git_ps1 " (%s)")\$ '
34-
-----
34+
----
3535

3636
The `\w` means print the current working directory, the `\$` prints the `$` part of the prompt, and `__git_ps1 " (%s)"` calls the function provided by `git-prompt.sh` with a formatting argument.
3737
Now your bash prompt will look like this when you're anywhere inside a Git-controlled project:
3838

39-
.Customized `bash` prompt.
40-
image::images/git-bash.png[Customized `bash` prompt.]
39+
.Customized `bash` prompt
40+
image::images/git-bash.png[Customized `bash` prompt]
4141

4242
Both of these scripts come with helpful documentation; take a look at the contents of `git-completion.bash` and `git-prompt.sh` for more information.

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

Lines changed: 0 additions & 10 deletions
This file was deleted.

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

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ But plain text isn't the best choice for all tasks; sometimes a visual represent
77

88
It's important to note that different interfaces are tailored for different workflows.
99
Some clients expose only a carefully curated subset of Git functionality, in order to support a specific way of working that the author considers effective.
10-
When viewed in this light, none of these tools can be called ``better'' than any of the others, they're simply more fit for their intended purpose.
10+
When viewed in this light, none of these tools can be called "`better`" than any of the others, they're simply more fit for their intended purpose.
1111
Also note that there's nothing these graphical clients can do that the command-line client can't; the command-line is still where you'll have the most power and control when working with your repositories.
1212

1313
==== `gitk` and `git-gui`
@@ -31,8 +31,8 @@ Gitk accepts many command-line options, most of which are passed through to the
3131
Probably one of the most useful is the `--all` flag, which tells gitk to show commits reachable from _any_ ref, not just HEAD.
3232
Gitk's interface looks like this:
3333

34-
.The `gitk` history viewer.
35-
image::images/gitk.png[The `gitk` history viewer.]
34+
.The `gitk` history viewer
35+
image::images/gitk.png[The `gitk` history viewer]
3636

3737
On the top is something that looks a bit like the output of `git log --graph`; each dot represents a commit, the lines represent parent relationships, and refs are shown as colored boxes.
3838
The yellow dot represents HEAD, and the red dot represents changes that are yet to become a commit.
@@ -43,14 +43,14 @@ In between is a collection of controls used for searching history.
4343
It, too, is easiest to invoke from the command line:
4444

4545
[source,console]
46-
-----
46+
----
4747
$ git gui
48-
-----
48+
----
4949

5050
And it looks something like this:
5151

52-
.The `git-gui` commit tool.
53-
image::images/git-gui.png[The `git-gui` commit tool.]
52+
.The `git-gui` commit tool
53+
image::images/git-gui.png[The `git-gui` commit tool]
5454

5555
On the left is the index; unstaged changes are on top, staged changes on the bottom.
5656
You can move entire files between the two states by clicking on their icons, or you can select a file for viewing by clicking on its name.
@@ -59,35 +59,34 @@ At top right is the diff view, which shows the changes for the currently-selecte
5959
You can stage individual hunks (or individual lines) by right-clicking in this area.
6060

6161
At the bottom right is the message and action area.
62-
Type your message into the text box and click ``Commit'' to do something similar to `git commit`.
63-
You can also choose to amend the last commit by choosing the ``Amend'' radio button, which will update the ``Staged Changes'' area with the contents of the last commit.
64-
Then you can simply stage or unstage some changes, alter the commit message, and click ``Commit'' again to replace the old commit with a new one.
62+
Type your message into the text box and click "`Commit`" to do something similar to `git commit`.
63+
You can also choose to amend the last commit by choosing the "`Amend`" radio button, which will update the "`Staged Changes`" area with the contents of the last commit.
64+
Then you can simply stage or unstage some changes, alter the commit message, and click "`Commit`" again to replace the old commit with a new one.
6565

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+
==== GitHub for macOS and Windows
6970

70-
==== GitHub for Mac and Windows
71-
72-
(((GitHub for Mac)))(((GitHub for Windows)))
73-
GitHub has created two workflow-oriented Git clients: one for Windows, and one for Mac.
71+
(((GitHub for macOS)))(((GitHub for Windows)))
72+
GitHub has created two workflow-oriented Git clients: one for Windows, and one for macOS.
7473
These clients are a good example of workflow-oriented tools – rather than expose _all_ of Git's functionality, they instead focus on a curated set of commonly-used features that work well together.
7574
They look like this:
7675

77-
.GitHub for Mac.
78-
image::images/github_mac.png[GitHub for Mac.]
76+
.GitHub for macOS
77+
image::images/github_mac.png[GitHub for macOS]
7978

80-
.GitHub for Windows.
81-
image::images/github_win.png[GitHub for Windows.]
79+
.GitHub for Windows
80+
image::images/github_win.png[GitHub for Windows]
8281

8382
They are designed to look and work very much alike, so we'll treat them like a single product in this chapter.
84-
We won't be doing a detailed rundown of these tools (they have their own documentation), but a quick tour of the ``changes'' view (which is where you'll spend most of your time) is in order.
83+
We won't be doing a detailed rundown of these tools (they have their own documentation), but a quick tour of the "`changes`" view (which is where you'll spend most of your time) is in order.
8584

86-
* On the left is the list of repositories the client is tracking; you can add a repository (either by cloning or attaching locally) by clicking the ``+'' icon at the top of this area.
85+
* On the left is the list of repositories the client is tracking; you can add a repository (either by cloning or attaching locally) by clicking the "`+`" icon at the top of this area.
8786
* In the center is a commit-input area, which lets you input a commit message, and select which files should be included.
88-
(On Windows, the commit history is displayed directly below this; on Mac, it's on a separate tab.)
87+
On Windows, the commit history is displayed directly below this; on macOS, it's on a separate tab.
8988
* On the right is a diff view, which shows what's changed in your working directory, or which changes were included in the selected commit.
90-
* The last thing to notice is the ``Sync'' button at the top-right, which is the primary way you interact over the network.
89+
* The last thing to notice is the "`Sync`" button at the top-right, which is the primary way you interact over the network.
9190

9291
[NOTE]
9392
====
@@ -97,12 +96,12 @@ While they're designed to highlight GitHub's service and recommended workflow, t
9796

9897
===== Installation
9998

100-
GitHub for Windows can be downloaded from https://windows.github.com[], and GitHub for Mac from https://mac.github.com[].
99+
GitHub for Windows can be downloaded from https://windows.github.com[], and GitHub for macOS from https://mac.github.com[].
101100
When the applications are first run, they walk you through all the first-time Git setup, such as configuring your name and email address, and both set up sane defaults for many common configuration options, such as credential caches and CRLF behavior.
102101

103-
Both are ``evergreen'' – updates are downloaded and installed in the background while the applications are open.
102+
Both are "`evergreen`" – updates are downloaded and installed in the background while the applications are open.
104103
This helpfully includes a bundled version of Git, which means you probably won't have to worry about manually updating it again.
105-
On Windows, the client includes a shortcut to launch Powershell with Posh-git, which we'll talk more about later in this chapter.
104+
On Windows, the client includes a shortcut to launch PowerShell with Posh-git, which we'll talk more about later in this chapter.
106105

107106
The next step is to give the tool some repositories to work with.
108107
The client shows you a list of the repositories you have access to on GitHub, and can clone them in one step.
@@ -111,25 +110,25 @@ If you already have a local repository, just drag its directory from the Finder
111110
===== Recommended Workflow
112111

113112
Once it's installed and configured, you can use the GitHub client for many common Git tasks.
114-
The intended workflow for this tool is sometimes called the ``GitHub Flow.''
115-
We cover this in more detail in <<ch06-github#r_github_flow>>, but the general gist is that (a) you'll be committing to a branch, and (b) you'll be syncing up with a remote repository fairly regularly.
113+
The intended workflow for this tool is sometimes called the "`GitHub Flow.`"
114+
We cover this in more detail in <<ch06-github#ch06-github_flow>>, but the general gist is that (a) you'll be committing to a branch, and (b) you'll be syncing up with a remote repository fairly regularly.
116115

117116
Branch management is one of the areas where the two tools diverge.
118-
On Mac, there's a button at the top of the window for creating a new branch:
117+
On macOS, there's a button at the top of the window for creating a new branch:
119118

120-
.``Create Branch'' button on Mac.
121-
image::images/branch_widget_mac.png[``Create Branch'' button on Mac.]
119+
."`Create Branch`" button on macOS
120+
image::images/branch_widget_mac.png[Create Branch button on macOS]
122121

123122
On Windows, this is done by typing the new branch's name in the branch-switching widget:
124123

125-
.Creating a branch on Windows.
126-
image::images/branch_widget_win.png[Creating a branch on Windows.]
124+
.Creating a branch on Windows
125+
image::images/branch_widget_win.png[Creating a branch on Windows]
127126

128127
Once your branch is created, making new commits is fairly straightforward.
129128
Make some changes in your working directory, and when you switch to the GitHub client window, it will show you which files changed.
130-
Enter a commit message, select the files you'd like to include, and click the ``Commit'' button (ctrl-enter or ⌘-enter).
129+
Enter a commit message, select the files you'd like to include, and click the "`Commit`" button (ctrl-enter or ⌘-enter).
131130

132-
The main way you interact with other repositories over the network is through the ``Sync'' feature.
131+
The main way you interact with other repositories over the network is through the "`Sync`" feature.
133132
Git internally has separate operations for pushing, fetching, merging, and rebasing, but the GitHub clients collapse all of these into one multi-step feature.
134133
Here's what happens when you click the Sync button:
135134

@@ -149,5 +148,5 @@ However, if your workflow is different, or you want more control over how and wh
149148
==== Other GUIs
150149

151150
There are a number of other graphical Git clients, and they run the gamut from specialized, single-purpose tools all the way to apps that try to expose everything Git can do.
152-
The official Git website has a curated list of the most popular clients at http://git-scm.com/downloads/guis[].
151+
The official Git website has a curated list of the most popular clients at https://git-scm.com/downloads/guis[].
153152
A more comprehensive list is available on the Git wiki site, at https://git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools#Graphical_Interfaces[].
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
=== Git in IntelliJ / PyCharm / WebStorm / PhpStorm / RubyMine
2+
3+
JetBrains IDEs (such as IntelliJ IDEA, PyCharm, WebStorm, PhpStorm, RubyMine, and others) ship with a Git Integration plugin.
4+
It provides a dedicated view in the IDE to work with Git and GitHub Pull Requests.
5+
6+
.Version Control ToolWindow in JetBrains IDEs
7+
image::images/jb.png[Version Control ToolWindow in JetBrains IDEs]
8+
9+
The integration relies on the command-line git client, and requires one to be installed.
10+
The official documentation is available at https://www.jetbrains.com/help/idea/using-git-integration.html[].
Lines changed: 78 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,86 @@
1-
[[r_git_powershell]]
2-
=== Git in Powershell
1+
[[_git_powershell]]
2+
=== Git in PowerShell
33

4-
(((powershell)))(((tab completion, powershell)))(((shell prompts, powershell)))
4+
(((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.
7-
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.
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 Core on Linux or macOS.
8+
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

10-
.Powershell with Posh-git.
11-
image::images/posh-git.png[Powershell with Posh-git.]
11+
.PowerShell with Posh-git
12+
image::images/posh-git.png[PowerShell with Posh-git]
1213

13-
Just download a Posh-Git release from (https://github.com/dahlbyk/posh-git[]), and uncompress it to the `WindowsPowershell` directory.
14-
Then open a Powershell prompt as the administrator, and do this:
14+
==== Installation
15+
16+
===== Prerequisites (Windows only)
17+
18+
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`).
19+
If you choose `AllSigned` instead of `RemoteSigned`, also local scripts (your own) need to be digitally signed in order to be executed.
20+
With `RemoteSigned`, only scripts having the `ZoneIdentifier` set to `Internet` (were downloaded from the web) need to be signed, others not.
21+
If you're an administrator and want to set it for all users on that machine, use `-Scope LocalMachine`.
22+
If you're a normal user, without administrative rights, you can use `-Scope CurrentUser` to set it only for you.
23+
24+
More about PowerShell Scopes: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scopes[].
25+
26+
More about PowerShell ExecutionPolicy: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy[].
27+
28+
To set the value of `ExecutionPolicy` to `RemoteSigned` for all users use the next command:
29+
30+
[source,powershell]
31+
----
32+
> Set-ExecutionPolicy -Scope LocalMachine -ExecutionPolicy RemoteSigned -Force
33+
----
34+
35+
===== PowerShell Gallery
36+
37+
If you have at least PowerShell 5 or PowerShell 4 with PackageManagement installed, you can use the package manager to install posh-git for you.
38+
39+
More information about PowerShell Gallery: https://docs.microsoft.com/en-us/powershell/scripting/gallery/overview[].
1540

1641
[source,powershell]
17-
-----
18-
> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm
19-
> cd ~\Documents\WindowsPowerShell\posh-git
20-
> .\install.ps1
21-
-----
42+
----
43+
> Install-Module posh-git -Scope CurrentUser -Force
44+
> Install-Module posh-git -Scope CurrentUser -AllowPrerelease -Force # Newer beta version with PowerShell Core support
45+
----
46+
47+
If you want to install posh-git for all users, use `-Scope AllUsers` instead and execute the command from an elevated PowerShell console.
48+
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:
49+
50+
[source,powershell]
51+
----
52+
> Install-Module PowerShellGet -Force -SkipPublisherCheck
53+
----
54+
55+
Then you can go back and try again.
56+
This happens, because the modules that ship with Windows PowerShell are signed with a different publishment certificate.
57+
58+
===== Update PowerShell Prompt
59+
60+
To include git information in your prompt, the posh-git module needs to be imported.
61+
To have posh-git imported every time PowerShell starts, execute the `Add-PoshGitToProfile` command which will add the import statement into your `$profile` script.
62+
This script is executed everytime you open a new PowerShell console.
63+
Keep in mind, that there are multiple `$profile` scripts.
64+
E. g. one for the console and a separate one for the ISE.
65+
66+
[source,powershell]
67+
----
68+
> Import-Module posh-git
69+
> Add-PoshGitToProfile -AllHosts
70+
----
71+
72+
===== From Source
73+
74+
Just download a posh-git release from https://github.com/dahlbyk/posh-git/releases[], and uncompress it.
75+
Then import the module using the full path to the `posh-git.psd1` file:
76+
77+
[source,powershell]
78+
----
79+
> Import-Module <path-to-uncompress-folder>\src\posh-git.psd1
80+
> Add-PoshGitToProfile -AllHosts
81+
----
82+
83+
This will add the proper line to your `profile.ps1` file, and posh-git will be active the next time you open PowerShell.
2284

23-
This will add the proper line to your `profile.ps1` file, and posh-git will be active the next time you open your prompt.
85+
For a description of the Git status summary information displayed in the prompt see: https://github.com/dahlbyk/posh-git/blob/master/README.md#git-status-summary-information[]
86+
For more details on how to customize your posh-git prompt see: https://github.com/dahlbyk/posh-git/blob/master/README.md#customization-variables[].
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
=== Git in Sublime Text
2+
3+
From version 3.2 onwards, Sublime Text has git integration in the editor.
4+
5+
The features are:
6+
7+
* The sidebar will show the git status of files and folders with a badge/icon.
8+
* Files and folders that are in your .gitignore file will be faded out in the sidebar.
9+
* In the status bar, you can see the current git branch and how many modifications you have made.
10+
* All changes to a file are now visible via markers in the gutter.
11+
* You can use part of the Sublime Merge git client functionality from within Sublime Text.
12+
This requires that Sublime Merge is installed. See: https://www.sublimemerge.com/[].
13+
14+
The official documentation for Sublime Text can be found here: https://www.sublimetext.com/docs/3/git_integration.html[].

0 commit comments

Comments
 (0)