You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/desktop/configuring-and-customizing-github-desktop/configuring-git-for-github-desktop.md
+44-5Lines changed: 44 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ Configuring your global author information in {% data variables.product.prodname
43
43
{% data reusables.desktop.windows-choose-options %}
44
44
1. In the "Options" window, click **Git**.
45
45
46
-

46
+

47
47
48
48
{% data reusables.desktop.name-field-git-config %}
49
49
{% data reusables.desktop.select-email-git-config %}
@@ -89,23 +89,62 @@ You can configure the default branch that will be used when you create a new rep
89
89
90
90
{% data reusables.desktop.mac-select-desktop-menu %}
91
91
{% data reusables.desktop.settings-git-pane %}
92
-
1. Optional, under "Default branch name for new repositories" edit the name of the default branch as needed.
92
+
1. Click the **Default branch** tab.
93
+
1. Edit the name of the default branch as needed.
93
94
{% data reusables.desktop.click-save-git-config %}
94
95
95
96
{% endmac %}
96
97
97
98
{% windows %}
98
99
99
100
{% data reusables.desktop.windows-choose-options %}
100
-
1. In the Options window, click **Git**.
101
+
1. In the "Options" window, click **Git**.
101
102
102
-

103
+

103
104
104
-
1. Under "Default branch name for new repositories", select the default branch name you would like to use, or, to enter a custom name, select "Other...".
105
+
1. Click the **Default branch** tab.
106
+
1. Edit the name of the default branch as needed.
105
107
{% data reusables.desktop.click-save-git-config %}
106
108
107
109
{% endwindows %}
108
110
111
+
## Configuring your shell environment for Git hooks
112
+
113
+
{% data variables.product.prodname_desktop %} runs Git hooks in your configured shell environment. This means hooks have access to the same environment variables, shell configuration files (such as `.bash_profile` or `.zshrc`), and tools as when you run Git from the command line. Tools installed via version managers, such as `nvm` or `rbenv`, will also be available to your hooks.
114
+
115
+
You can configure hook environment settings in the **Hooks** tab of the **Git** settings pane.
116
+
117
+
{% mac %}
118
+
119
+
{% data reusables.desktop.mac-select-desktop-menu %}
120
+
{% data reusables.desktop.settings-git-pane %}
121
+
1. Click the **Hooks** tab.
122
+
123
+
{% endmac %}
124
+
125
+
{% windows %}
126
+
127
+
{% data reusables.desktop.windows-choose-options %}
128
+
1. In the "Options" window, click **Git**.
129
+
130
+

131
+
132
+
1. Click the **Hooks** tab.
133
+
134
+
{% endwindows %}
135
+
136
+
The following settings are available:
137
+
138
+
***Load Git hook environment variables from shell**: When enabled, {% data variables.product.prodname_desktop %} loads environment variables from your shell when executing Git hooks. Enable this if your hooks depend on tools installed via version managers such as `nvm`, `rbenv`, or `asdf`.
139
+
140
+
{% mac %}
141
+
142
+
***Cache Git hook environment variables**: Caches hook environment variables to improve performance. Disable this if your hooks rely on frequently changing environment variables.
143
+
144
+
{% endmac %}
145
+
146
+
For more information about Git hooks in {% data variables.product.prodname_desktop %}, see [AUTOTITLE](/desktop/making-changes-in-a-branch/working-with-git-hooks-in-github-desktop).
Copy file name to clipboardExpand all lines: content/desktop/making-changes-in-a-branch/committing-and-reviewing-changes-to-your-project-in-github-desktop.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -115,6 +115,10 @@ Once you're satisfied with the changes you've chosen to include in your commit,
115
115
116
116

117
117
{% data reusables.desktop.commit-button %}
118
+
119
+
> [!TIP]
120
+
> If your repository has pre-commit or commit-msg hooks, they will run automatically when you commit. You can bypass hooks for a specific commit by clicking {% octicon "gear" aria-label="Commit options" %} next to the commit message field and selecting **Bypass Commit Hooks**. For more information, see [AUTOTITLE](/desktop/making-changes-in-a-branch/working-with-git-hooks-in-github-desktop).
121
+
118
122
1. If the branch you're trying to commit to is protected, Desktop will warn you.
119
123
* To move your changes, click **switch branches**.
120
124
* To commit your changes to the protected branch, click **Commit to BRANCH**.
@@ -135,3 +139,4 @@ If you need to undo a commit or revise your commit history (to make it easier fo
intro: 'You can run Git hooks in your shell environment and bypass commit hooks directly from {% data variables.product.prodname_desktop %}.'
5
+
versions:
6
+
fpt: '*'
7
+
ghec: '*'
8
+
ghes: '*'
9
+
---
10
+
11
+
## About Git hooks in {% data variables.product.prodname_desktop %}
12
+
13
+
Git hooks are scripts that run automatically at specific points in the Git workflow, such as before or after a commit, push, or merge. They can be used to enforce code quality standards, run tests, or perform other automated tasks.
14
+
15
+
{% data variables.product.prodname_desktop %} runs Git hooks in your configured shell environment. Hooks have access to the same environment variables and tools as when you run Git from the command line. This means hooks that rely on tools installed via version managers (such as `nvm` or `rbenv`) or that depend on shell configuration files (such as `.bash_profile` or `.zshrc`) will work correctly.
16
+
17
+
Hook output is displayed in real time in the {% data variables.product.prodname_desktop %} UI, with terminal colors and formatting preserved, so you can easily read and debug the output from your hooks.
18
+
19
+
## Bypassing a commit hook
20
+
21
+
If you want to make a commit without running your pre-commit or commit-msg hooks, you can bypass them directly from {% data variables.product.prodname_desktop %}. This is equivalent to using `git commit --no-verify` on the command line.
22
+
23
+
You can bypass hooks preemptively before making a commit, or after a hook fails.
24
+
25
+
### Bypassing hooks before committing
26
+
27
+
1. In the "Changes" tab, write your commit message.
28
+
1. Next to the commit message field, click {% octicon "gear" aria-label="Commit options" %}.
29
+
1. Select **Bypass Commit Hooks**.
30
+
1. Click **Commit to BRANCH**.
31
+
32
+
### Bypassing a failed hook
33
+
34
+
If a commit hook fails, {% data variables.product.prodname_desktop %} will display the hook's output and give you the option to bypass the failed hook and proceed with the commit.
35
+
36
+
1. Review the hook output displayed by {% data variables.product.prodname_desktop %}.
37
+
1. To proceed with the commit despite the failure, click **Commit anyway**.
38
+
39
+
> [!WARNING]
40
+
> Bypassing commit hooks overrides quality and safety checks that your team may rely on. Only bypass a hook if you understand the implications.

3
+

0 commit comments