j1-template 2023.7.0 → 2023.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_includes/themes/j1/modules/searcher/procedures/topsearch.proc +2 -1
- data/_includes/themes/j1/procedures/global/create_bs_button.proc +0 -1
- data/_includes/themes/j1/procedures/global/create_word_cloud.proc +3 -2
- data/_includes/themes/j1/procedures/global/date-german.proc +2 -7
- data/_includes/themes/j1/procedures/global/get_category.proc +13 -19
- data/_includes/themes/j1/procedures/global/get_category_item.proc +29 -33
- data/_includes/themes/j1/procedures/global/get_documents_dir.proc +8 -8
- data/_includes/themes/j1/procedures/global/get_page_url.proc +9 -14
- data/_includes/themes/j1/procedures/global/select_color.proc +12 -17
- data/_includes/themes/j1/procedures/global/select_font_size.proc +31 -35
- data/_includes/themes/j1/procedures/global/select_icon_size.proc +38 -40
- data/_includes/themes/j1/procedures/global/select_location.proc +56 -59
- data/_includes/themes/j1/procedures/global/set_base_vars_folders.proc +2 -4
- data/_includes/themes/j1/procedures/global/set_image_block.proc +4 -2
- data/_includes/themes/j1/procedures/global/setup.proc +8 -3
- data/assets/data/masonry.html +13 -13
- data/assets/themes/j1/adapter/js/j1.js +39 -39
- data/assets/themes/j1/adapter/js/masterslider.js +2 -1
- data/assets/themes/j1/adapter/js/slick.js +13 -10
- data/assets/themes/j1/adapter/js/translator.js +62 -58
- data/assets/themes/j1/core/css/themes/unolight/bootstrap.css +70 -0
- data/assets/themes/j1/core/css/themes/unolight/bootstrap.min.css +1 -1
- data/assets/themes/j1/core/js/template.js +1339 -3
- data/assets/themes/j1/core/js/template.min.js +7 -7
- data/assets/themes/j1/core/js/template.min.js.map +1 -1
- data/assets/themes/j1/modules/carousel/css/theme/uno.css +5 -0
- data/assets/themes/j1/modules/carousel/css/theme/uno.min.css +1 -1
- data/assets/themes/j1/modules/masonry/css/theme/readme +1 -0
- data/assets/themes/j1/modules/masterslider/css/theme/uno.css +2 -3
- data/assets/themes/j1/modules/masterslider/css/theme/uno.min.css +1 -1
- data/assets/themes/j1/modules/slick/lightbox/css/theme/uno.css +13 -2
- data/assets/themes/j1/modules/slick/lightbox/css/theme/uno.min.css +1 -1
- data/assets/themes/j1/modules/slick/lightbox/js/slick-lightbox.js +373 -347
- data/assets/themes/j1/modules/slick/slider/css/theme/uno.css +20 -51
- data/assets/themes/j1/modules/slick/slider/css/theme/uno.min.css +2 -2
- data/lib/j1/version.rb +1 -1
- data/lib/starter_web/Gemfile +2 -2
- data/lib/starter_web/README.md +5 -5
- data/lib/starter_web/_config.yml +1 -1
- data/lib/starter_web/_data/blocks/banner.yml +8 -9
- data/lib/starter_web/_data/blocks/footer.yml +8 -10
- data/lib/starter_web/_data/modules/masonry.yml +9 -1
- data/lib/starter_web/_data/modules/masterslider.yml +69 -116
- data/lib/starter_web/_data/modules/navigator_menu.yml +58 -51
- data/lib/starter_web/_data/resources.yml +3 -3
- data/lib/starter_web/_data/templates/feed.xml +1 -1
- data/lib/starter_web/_includes/attributes.asciidoc +1 -0
- data/lib/starter_web/_plugins/asciidoctor/callout.rb +2 -2
- data/lib/starter_web/_plugins/asciidoctor/masterslider-block.rb +1 -1
- data/lib/starter_web/_plugins/asciidoctor/slick-block.rb +1 -1
- data/lib/starter_web/_plugins/index/lunr.rb +1 -1
- data/lib/starter_web/assets/images/collections/books/biography/a_life_in_questions.jpg +0 -0
- data/lib/starter_web/collections/posts/public/featured/_posts/0000-00-00-welcome-to-j1.adoc.erb +5 -5
- data/lib/starter_web/index.html +6 -6
- data/lib/starter_web/package.json +1 -1
- data/lib/starter_web/pages/public/blog/navigator/archive/categoryview.html +0 -1
- data/lib/starter_web/pages/public/tools/previewer/preview_bootstrap_theme.adoc +148 -140
- data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
- data/lib/starter_web/utilsrv/package.json +1 -1
- metadata +3 -75
- data/assets/themes/j1/modules/carousel/js/carousel.js +0 -1517
- data/assets/themes/j1/modules/carousel/js/carousel.min.js +0 -57
- data/assets/themes/j1/modules/masonry/css/theme/uno.css +0 -35
- data/assets/themes/j1/modules/masonry/css/theme/uno.min.css +0 -15
- data/assets/themes/j1/modules/speak2me/LICENSE +0 -21
- data/assets/themes/j1/modules/speak2me/js/speak2me.js +0 -947
- data/assets/themes/j1/modules/speak2me/js/speak2me.min.js +0 -26
- data/lib/starter_web/_data/modules/buymeacoffee.yml +0 -30
- data/lib/starter_web/_data/modules/defaults/buymeacoffee.yml +0 -30
- data/lib/starter_web/assets/images/modules/masterslider/slider_5/ms-free-food-restaurant-140x80.jpg +0 -0
- data/lib/starter_web/assets/images/modules/masterslider/slider_5/ms-free-food-restaurant.jpg +0 -0
- data/lib/starter_web/assets/images/modules/masterslider/slider_5/ms-free-food-single-man-140x80.jpg +0 -0
- data/lib/starter_web/assets/images/modules/masterslider/slider_5/ms-free-food-single-man.jpg +0 -0
- data/lib/starter_web/assets/images/modules/masterslider/slider_5/ms-free-food-single-woman-140x80.jpg +0 -0
- data/lib/starter_web/assets/images/modules/masterslider/slider_5/ms-free-food-single-woman.jpg +0 -0
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/attributes.asciidoc +0 -58
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/accordion.asciidoc +0 -34
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/alerts.asciidoc +0 -15
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/badges.asciidoc +0 -9
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/body.asciidoc +0 -14
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/breadcrumbs.asciidoc +0 -14
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/buttons.asciidoc +0 -75
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/cards.asciidoc +0 -22
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/carousel.asciidoc +0 -37
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/close.asciidoc +0 -15
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/code.asciidoc +0 -14
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/color_system.asciidoc +0 -353
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/components.asciidoc +0 -69
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/dropdowns.asciidoc +0 -53
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/figures.asciidoc +0 -5
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/forms.asciidoc +0 -270
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/grid.asciidoc +0 -49
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/links.asciidoc +0 -21
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/list_groups.asciidoc +0 -28
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/modals.asciidoc +0 -43
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/navbar.asciidoc +0 -45
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/navs.asciidoc +0 -28
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/offcanvas.asciidoc +0 -16
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/options.asciidoc +0 -30
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/pagination.asciidoc +0 -40
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/paragraph.asciidoc +0 -5
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/placeholders.asciidoc +0 -5
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/popovers.asciidoc +0 -28
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/position.asciidoc +0 -8
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/progress_bars.asciidoc +0 -12
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/spacing.asciidoc +0 -14
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/spinners.asciidoc +0 -12
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/tables.asciidoc +0 -55
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/thumbnails.asciidoc +0 -9
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/toasts.asciidoc +0 -18
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/tooltips.asciidoc +0 -28
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/typography.asciidoc +0 -115
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/documents/z_index.asciidoc +0 -26
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/tables/_table.asciidoc +0 -9
- data/lib/starter_web/pages/public/learn/bs_sass_variables/_includes/tables/accordion.asciidoc +0 -87
- data/lib/starter_web/pages/public/learn/bs_sass_variables/bs_sass_variables.adoc +0 -267
- data/lib/starter_web/pages/public/learn/core_web_vitals/_includes/attributes.asciidoc +0 -59
- data/lib/starter_web/pages/public/learn/core_web_vitals/_includes/documents/100_chapter.asciidoc +0 -541
- data/lib/starter_web/pages/public/learn/core_web_vitals/_includes/documents/200_chapter.asciidoc +0 -33
- data/lib/starter_web/pages/public/learn/core_web_vitals/_includes/tables/build_command_options.asciidoc +0 -72
- data/lib/starter_web/pages/public/learn/core_web_vitals/_includes/tables/files_and_folders.asciidoc +0 -66
- data/lib/starter_web/pages/public/learn/core_web_vitals/_includes/tables/global_configuration_options.asciidoc +0 -63
- data/lib/starter_web/pages/public/learn/core_web_vitals/_includes/tables/global_variables.asciidoc +0 -26
- data/lib/starter_web/pages/public/learn/core_web_vitals/_includes/tables/page_variables.asciidoc +0 -54
- data/lib/starter_web/pages/public/learn/core_web_vitals/_includes/tables/serve_command_options.asciidoc +0 -45
- data/lib/starter_web/pages/public/learn/core_web_vitals/_includes/tables/site_variables.asciidoc +0 -59
- data/lib/starter_web/pages/public/learn/core_web_vitals/core_web_vitals.adoc +0 -447
- data/lib/starter_web/pages/public/learn/roundtrip/lunr_search.1.asciidoc +0 -460
- data/lib/starter_web/pages/public/manuals/speak2me.adoc +0 -412
- data/lib/starter_web/pages/public/tools/cheatsheet/gem.adoc +0 -259
- data/lib/starter_web/pages/public/tools/cheatsheet/git.adoc +0 -1462
- data/lib/starter_web/pages/public/tools/cheatsheet/j1.adoc +0 -177
- data/lib/starter_web/pages/public/tools/cheatsheet/yaml.adoc +0 -522
@@ -1,1462 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: Git
|
3
|
-
tagline: Sheatsheet for daily use
|
4
|
-
|
5
|
-
date: 2023-05-19
|
6
|
-
#last_modified: 2023-01-01
|
7
|
-
|
8
|
-
description: >
|
9
|
-
J1 Template is a Bootstrap V5 website template for the static
|
10
|
-
site generator Jekyll.
|
11
|
-
The Cheatsheet discuss Git commands for daily use.
|
12
|
-
Many Git commands available from the command line.
|
13
|
-
Git offers rich features for version control, collaboration,
|
14
|
-
and project management.
|
15
|
-
keywords: >
|
16
|
-
Jekyll, Theme, JekyllOne, Cheatsheet, Git, Commandline
|
17
|
-
|
18
|
-
categories: [ Manual ]
|
19
|
-
tags: [ Cheatsheet, Git ]
|
20
|
-
|
21
|
-
image:
|
22
|
-
path: /assets/images/modules/attics/1920x1280/recha-oktaviani.jpg
|
23
|
-
width: 1920
|
24
|
-
height: 1280
|
25
|
-
|
26
|
-
regenerate: false
|
27
|
-
permalink: /pages/public/tools/cheatsheet/git/
|
28
|
-
|
29
|
-
resources: [ animate, clipboard, rouge ]
|
30
|
-
resource_options:
|
31
|
-
- attic:
|
32
|
-
slides:
|
33
|
-
- url: /assets/images/modules/attics/1920x1280/recha-oktaviani.jpg
|
34
|
-
alt: Photo by Recha Oktaviani on Unsplash
|
35
|
-
badge:
|
36
|
-
type: unsplash
|
37
|
-
author: Recha Oktaviani
|
38
|
-
href: https://unsplash.com/de/@rechaoktaviani
|
39
|
-
---
|
40
|
-
|
41
|
-
// Page Initializer
|
42
|
-
// =============================================================================
|
43
|
-
// Enable the Liquid Preprocessor
|
44
|
-
:page-liquid:
|
45
|
-
|
46
|
-
// Set (local) page attributes here
|
47
|
-
// -----------------------------------------------------------------------------
|
48
|
-
// :page--attr: <attr-value>
|
49
|
-
|
50
|
-
// Load Liquid procedures
|
51
|
-
// -----------------------------------------------------------------------------
|
52
|
-
{% capture load_attributes %}themes/{{site.template.name}}/procedures/global/attributes_loader.proc{%endcapture%}
|
53
|
-
|
54
|
-
// Load page attributes
|
55
|
-
// -----------------------------------------------------------------------------
|
56
|
-
{% include {{load_attributes}} scope="global" %}
|
57
|
-
|
58
|
-
// Page content
|
59
|
-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
60
|
-
|
61
|
-
// Include sub-documents (if any)
|
62
|
-
// -----------------------------------------------------------------------------
|
63
|
-
[role="dropcap"]
|
64
|
-
The Cheatsheet discuss Git commands for daily use. Many Git commands are available
|
65
|
-
from the command line. Git offers rich features for version control,
|
66
|
-
collaboration, and project management. You can explore more Git commands
|
67
|
-
and options in the official Git documentation.
|
68
|
-
|
69
|
-
[role="mt-5"]
|
70
|
-
== Git status colors
|
71
|
-
|
72
|
-
In the Git version control system, the output of the git status command can
|
73
|
-
be displayed with different colors to provide visual cues about the state of
|
74
|
-
your repository. The colors help you quickly identify modified, added,
|
75
|
-
deleted, or untracked files, among other things. The specific colors used
|
76
|
-
can depend on your terminal configuration, but here are the default colors
|
77
|
-
commonly used by Git:
|
78
|
-
|
79
|
-
* Untracked files: Untracked files are displayed in red color by default.
|
80
|
-
These are files that Git is not currently tracking.
|
81
|
-
* Modified files: Modified files are displayed in green color by default.
|
82
|
-
These files have been modified but still need to be staged for commit.
|
83
|
-
* Staged files: Staged files, ready to be committed, are usually displayed
|
84
|
-
in a different color from modified files. By default, staged files are
|
85
|
-
not assigned a specific color, but they appear in a separate section
|
86
|
-
from modified files.
|
87
|
-
* Renamed or moved files: Renamed or moved files are displayed in green,
|
88
|
-
indicating that they have been renamed or moved since the last commit.
|
89
|
-
* Deleted files: Deleted files are displayed in red, indicating that they
|
90
|
-
have been removed from the repository.
|
91
|
-
* Unmerged files: Unmerged files, resulting from conflicts during a merge
|
92
|
-
operation, are typically displayed in a different color, such as yellow or purple.
|
93
|
-
|
94
|
-
It's important to note that the actual colors displayed may vary depending
|
95
|
-
on your terminal configuration and settings. You can customize the colors
|
96
|
-
used by Git by modifying your terminal's color scheme or configuring
|
97
|
-
Git-specific color options in your Git configuration file (~/.gitconfig).
|
98
|
-
|
99
|
-
[source, ini]
|
100
|
-
----
|
101
|
-
[color "status"]
|
102
|
-
ignored = grey
|
103
|
-
added = yellow
|
104
|
-
changed = green
|
105
|
-
deleted = red
|
106
|
-
new = orange
|
107
|
-
untracked = magenta
|
108
|
-
----
|
109
|
-
|
110
|
-
.Default color scheme
|
111
|
-
[cols="4a,8a", options="header", width="100%", role="rtable mt-3"]
|
112
|
-
|===
|
113
|
-
|Color |Description
|
114
|
-
|
115
|
-
|`grey`
|
116
|
-
|*Ignored* file or folder by `.gitignore`.
|
117
|
-
|
118
|
-
|`green`
|
119
|
-
|*New* file or folder.
|
120
|
-
|
121
|
-
|`orange`
|
122
|
-
|*Modified* file or folder.
|
123
|
-
|
124
|
-
|`red`
|
125
|
-
|*Deleted* file or folder.
|
126
|
-
|
127
|
-
|`blue`
|
128
|
-
|*Untracked* file or folder (may NOT used by Atom).
|
129
|
-
|
130
|
-
|===
|
131
|
-
|
132
|
-
|
133
|
-
[role="mt-5"]
|
134
|
-
== Git Aliases
|
135
|
-
|
136
|
-
Git aliases allow you to create shortcuts or alternative names for Git
|
137
|
-
commands and workflows, making it easier and faster to execute common
|
138
|
-
operations. You can define aliases in your personal Git configuration file
|
139
|
-
`~/.gitconfig`, either globally for all repositories or locally for a
|
140
|
-
specific repository.
|
141
|
-
|
142
|
-
[source, ini]
|
143
|
-
----
|
144
|
-
[alias]
|
145
|
-
ad = add .
|
146
|
-
br = branch
|
147
|
-
co = commit -am
|
148
|
-
cs = commit --amend --no-edit
|
149
|
-
ce = commit --amend
|
150
|
-
cr = reset HEAD~1 --soft
|
151
|
-
cd = reset HEAD~1 --hard
|
152
|
-
cl = clone
|
153
|
-
ck = checkout
|
154
|
-
df = diff
|
155
|
-
dw = diff --word-diff
|
156
|
-
he = help
|
157
|
-
hi = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
|
158
|
-
la = ls-files
|
159
|
-
ll = ls-tree --full-tree -r --name-only HEAD
|
160
|
-
lg = log --stat
|
161
|
-
pu = push
|
162
|
-
rm = rm -r --cached .
|
163
|
-
rf = rm -rf --cached .
|
164
|
-
st = status
|
165
|
-
ty = 'cat-file'
|
166
|
-
----
|
167
|
-
|
168
|
-
[role="mt-5"]
|
169
|
-
== Branch Commands
|
170
|
-
|
171
|
-
Git is a distributed version control system that allows you to manage
|
172
|
-
multiple code branches within a repository. A branch in is used to keep
|
173
|
-
your *changes* until they are *ready*. You can do your work on a branch
|
174
|
-
like *develop* while the main branch (main) remains stable (unchanged).
|
175
|
-
After you are done (on the branch *develop* for example), you can *merge*
|
176
|
-
the changes it to the main branch for a new stable version.
|
177
|
-
|
178
|
-
[cols="3a, 4a, 5a", options="header", width="100%", role="rtable mt-3 mb-5"]
|
179
|
-
|===
|
180
|
-
|Command |Description |Example
|
181
|
-
|
182
|
-
|`branch`
|
183
|
-
|Display a list of *local* branches in your repository.
|
184
|
-
|
|
185
|
-
[source, sh]
|
186
|
-
----
|
187
|
-
git branch
|
188
|
-
----
|
189
|
-
|
190
|
-
|`branch -a`
|
191
|
-
|Display a list of both *local* and *remote* branches in your repository.
|
192
|
-
|
|
193
|
-
[source, sh]
|
194
|
-
----
|
195
|
-
git branch -a
|
196
|
-
----
|
197
|
-
|
198
|
-
|`branch -d <branch-name>`
|
199
|
-
|Delete a *local* branch. This will *not* work if the branch to
|
200
|
-
delete *has unmerged changes*.
|
201
|
-
|
|
202
|
-
[source, sh]
|
203
|
-
----
|
204
|
-
git branch -d dummy_branch
|
205
|
-
----
|
206
|
-
|
207
|
-
|`branch -D <branch-name>`
|
208
|
-
|Delete a *local* branch *with unmerged changes*.
|
209
|
-
|
|
210
|
-
[source, sh]
|
211
|
-
----
|
212
|
-
git branch -D dummy_branch
|
213
|
-
----
|
214
|
-
|
215
|
-
|`branch -m <branch-name> <new-branch-name>`
|
216
|
-
|Rename a *local* branch.
|
217
|
-
|
|
218
|
-
[source, sh]
|
219
|
-
----
|
220
|
-
git branch -m master main
|
221
|
-
----
|
222
|
-
|
223
|
-
|`branch -m <branch-name>`
|
224
|
-
|Rename the *current* local branch
|
225
|
-
|
|
226
|
-
[source, sh]
|
227
|
-
----
|
228
|
-
git branch -m main
|
229
|
-
----
|
230
|
-
|
231
|
-
|`branch -r`
|
232
|
-
|Display a list of *remote* branches in your repository.
|
233
|
-
|
|
234
|
-
[source, sh]
|
235
|
-
----
|
236
|
-
git branch -r
|
237
|
-
----
|
238
|
-
|
239
|
-
|`push <remote> --delete <remote branch>`
|
240
|
-
|Delete a *remote* branch.
|
241
|
-
|
|
242
|
-
[source, sh]
|
243
|
-
----
|
244
|
-
git push origin --delete dummy_branch
|
245
|
-
----
|
246
|
-
|
247
|
-
|`push --set-upstream <remote branch>`
|
248
|
-
|Set an *upstream* branch. Running this command will push your *local*
|
249
|
-
branch to the new *remote* branch.
|
250
|
-
|
|
251
|
-
[source, sh]
|
252
|
-
----
|
253
|
-
git push --set-upstream dummy_branch
|
254
|
-
----
|
255
|
-
|===
|
256
|
-
|
257
|
-
|
258
|
-
== Checkout Commands
|
259
|
-
|
260
|
-
The `git checkout` command is used to *switch* between *branches*,
|
261
|
-
create new branches, or restore files to a *previous state*.
|
262
|
-
|
263
|
-
[cols="3a, 4a, 5a", options="header", width="100%", role="rtable mt-3 mb-5"]
|
264
|
-
|===
|
265
|
-
|Command |Description |Example
|
266
|
-
|
267
|
-
|`checkout <branch-name>`
|
268
|
-
|Switch to a different branch.
|
269
|
-
|
|
270
|
-
[source, sh]
|
271
|
-
----
|
272
|
-
git checkout main
|
273
|
-
----
|
274
|
-
|
275
|
-
|`checkout -b <branch-name>`
|
276
|
-
|*Create* a new branch and switch to it.
|
277
|
-
|
|
278
|
-
[source, sh]
|
279
|
-
----
|
280
|
-
git checkout -b develop
|
281
|
-
----
|
282
|
-
|
283
|
-
|`checkout -b <branch-name> <remote-name>/<branch-name>`
|
284
|
-
|Create a *local* branch from a *remote* (branch) and checkout that branch.
|
285
|
-
|
|
286
|
-
[source, sh]
|
287
|
-
----
|
288
|
-
git checkout -b dummy origin/dummy_branch
|
289
|
-
----
|
290
|
-
|
291
|
-
|`checkout <commit hash>`
|
292
|
-
|Checkout from a *previously* created (existing) commit.
|
293
|
-
|
|
294
|
-
[source, sh]
|
295
|
-
----
|
296
|
-
git checkout 4b4690d00
|
297
|
-
----
|
298
|
-
|
299
|
-
|`checkout -b <branch-name> <commit hash>`
|
300
|
-
|Checkout from a *previously* created (existing) commit `<commit hash>`
|
301
|
-
to a new *local* branch `<branch-name>`.
|
302
|
-
|
|
303
|
-
[source, sh]
|
304
|
-
----
|
305
|
-
git checkout -b new_branch 4b4690d00
|
306
|
-
----
|
307
|
-
|
308
|
-
|`checkout <tag name>`
|
309
|
-
|Checkout a branch based on a *tag* in a detached HEAD state.
|
310
|
-
|
|
311
|
-
[source, sh]
|
312
|
-
----
|
313
|
-
git checkout v2023.2.6
|
314
|
-
----
|
315
|
-
|
316
|
-
|`checkout -b <branch-name> <tag-name>`
|
317
|
-
|Checkout a *new* local branch `<branch-name>` based on a *tag*.
|
318
|
-
|
|
319
|
-
[source, sh]
|
320
|
-
----
|
321
|
-
git checkout -b b2023.2.6 v2023.2.6
|
322
|
-
----
|
323
|
-
|
324
|
-
|===
|
325
|
-
|
326
|
-
.Detached HEAD state
|
327
|
-
[TIP]
|
328
|
-
====
|
329
|
-
In Git, the *detached HEAD* state refers to a situation where the
|
330
|
-
currently checked out commit is *not* associated with a *branch*. Instead
|
331
|
-
of being on a branch, the HEAD points directly to a specific *commit*.
|
332
|
-
|
333
|
-
When you typically work on a branch in Git, the HEAD is associated with that
|
334
|
-
branch, and any new commits you create will be added to the branch's history.
|
335
|
-
However, in a detached HEAD state, any new commits you create will not be
|
336
|
-
part of any branch. The HEAD points directly to the commit.
|
337
|
-
====
|
338
|
-
|
339
|
-
[role="mt-5"]
|
340
|
-
== Cherry Pick Commands
|
341
|
-
|
342
|
-
The `git cherry-pick` command is used to apply *specific commits* from
|
343
|
-
one branch to another. It lets you pick *individual commits* and apply
|
344
|
-
them to the *current branch*.
|
345
|
-
|
346
|
-
CAUTION: Some commonly used `cherry-pick` commands allow you to apply
|
347
|
-
commits from one branch to another selectively. It is important to note
|
348
|
-
that cherry-picking can introduce *conflicts*, especially if the same
|
349
|
-
changes have been made in *different* branches.
|
350
|
-
|
351
|
-
The command takes changes from a target commit and places them on
|
352
|
-
the HEAD of the currently checked out branch. From here, you can either
|
353
|
-
continue working with these changes in your working directory or you can
|
354
|
-
immediately commit the changes onto the new branch.
|
355
|
-
|
356
|
-
[cols="3a, 4a, 5a", options="header", width="100%", role="rtable mt-3 mb-5"]
|
357
|
-
|===
|
358
|
-
|Command |Description |Example
|
359
|
-
|
360
|
-
|`cherry-pick <commit_hash>`
|
361
|
-
|Apply a commit’s changes onto a different branch.
|
362
|
-
|
|
363
|
-
[source, sh]
|
364
|
-
----
|
365
|
-
git cherry-pick <commit_hash>
|
366
|
-
----
|
367
|
-
|
368
|
-
|`cherry-pick <commit_hash1> <commit_hash2>`
|
369
|
-
|Apply changes from multiple commits to the current branch. The commits are
|
370
|
-
applied in the order specified.
|
371
|
-
|
|
372
|
-
[source, sh]
|
373
|
-
----
|
374
|
-
git cherry-pick <commit_hash1> <commit_hash2>
|
375
|
-
----
|
376
|
-
|
377
|
-
|`cherry-pick -n <commit_hash>`
|
378
|
-
|Perform a *no commit* cherry-pick, which applies the changes from the
|
379
|
-
specified commit but does not create a new commit. This allows you to
|
380
|
-
modify the changes before committing them.
|
381
|
-
|
|
382
|
-
[source, sh]
|
383
|
-
----
|
384
|
-
git cherry-pick -n <commit_hash>
|
385
|
-
----
|
386
|
-
|
387
|
-
|`cherry-pick --edit <commit_hash>`
|
388
|
-
|Opens the commit message editor before committing the cherry-picked
|
389
|
-
changes. It allows you to modify the commit message.
|
390
|
-
|
|
391
|
-
[source, sh]
|
392
|
-
----
|
393
|
-
git cherry-pick --edit <commit_hash>
|
394
|
-
----
|
395
|
-
|
396
|
-
|`cherry-pick --continue`
|
397
|
-
|Continues the cherry-pick process after resolving any conflicts that
|
398
|
-
occurred during the cherry-pick operation.
|
399
|
-
|
|
400
|
-
[source, sh]
|
401
|
-
----
|
402
|
-
git cherry-pick --continue
|
403
|
-
----
|
404
|
-
|
405
|
-
|`cherry-pick --abort`
|
406
|
-
|Aborts the cherry-pick operation and returns the branch to its original
|
407
|
-
state before the cherry-pick was started.
|
408
|
-
|
|
409
|
-
[source, sh]
|
410
|
-
----
|
411
|
-
git cherry-pick --abort
|
412
|
-
----
|
413
|
-
|
414
|
-
|===
|
415
|
-
|
416
|
-
TIP: The cherry pick command can be helpful if you accidentally make a
|
417
|
-
commit to the *wrong branch*. Cherry picking allows you to get those
|
418
|
-
changes onto the correct branch without redoing any work. After the
|
419
|
-
commit it’s been cherry picked, you can either continue working
|
420
|
-
with the changes before committing, or you can immediately commit
|
421
|
-
the changes onto the target branch.
|
422
|
-
|
423
|
-
|
424
|
-
[role="mt-5"]
|
425
|
-
== Clone Commands
|
426
|
-
|
427
|
-
The git clone command creates a copy of a Git repository in a new directory.
|
428
|
-
It retrieves the entire repository, including all its files, branches, and
|
429
|
-
commit history.
|
430
|
-
|
431
|
-
[cols="3a, 4a, 5a", options="header", width="100%", role="rtable mt-3 mb-3"]
|
432
|
-
|===
|
433
|
-
|Command |Description |Example
|
434
|
-
|
435
|
-
|`clone <repository-url>`
|
436
|
-
|Clone a specified remote repository.
|
437
|
-
|
|
438
|
-
[source, sh]
|
439
|
-
----
|
440
|
-
git clone <repository-url>
|
441
|
-
----
|
442
|
-
|
443
|
-
|`clone <repository-url> <directory-name>`
|
444
|
-
|Clone a repository and name the local directory.
|
445
|
-
|
|
446
|
-
[source, sh]
|
447
|
-
----
|
448
|
-
git clone <repository-url> <directory-name>
|
449
|
-
----
|
450
|
-
|
451
|
-
|`clone <repository-url> --origin <name>`
|
452
|
-
|Clone a repository and name the remote (`<name>`). If you do not wish
|
453
|
-
to name the remote, Git will provide the default name `origin`.
|
454
|
-
|
|
455
|
-
[source, sh]
|
456
|
-
----
|
457
|
-
git clone <repository-url> --origin <name>
|
458
|
-
----
|
459
|
-
|
460
|
-
|`clone <repository-url> --branch <branch-name>`
|
461
|
-
|Clone a repository and checkout the specific branch.
|
462
|
-
|
|
463
|
-
[source, sh]
|
464
|
-
----
|
465
|
-
git clone <repository-url> --branch <branch-name>
|
466
|
-
----
|
467
|
-
|
468
|
-
|`clone <repository-url> --depth <depth>`
|
469
|
-
|Clone a repository with a specified number of commits (`<depth>`).
|
470
|
-
|
|
471
|
-
[source, sh]
|
472
|
-
----
|
473
|
-
git clone <repository-url> --depth <depth>
|
474
|
-
----
|
475
|
-
|
476
|
-
|`clone <repository-url> --no-tags`
|
477
|
-
|Clone a repository without copying the repo’s tags.
|
478
|
-
|
|
479
|
-
[source, sh]
|
480
|
-
----
|
481
|
-
git clone <repository-url> --no-tags
|
482
|
-
----
|
483
|
-
|
484
|
-
|===
|
485
|
-
|
486
|
-
[role="mb-4"]
|
487
|
-
Here’s what each part of the command means:
|
488
|
-
|
489
|
-
* `<repository_url>`, this is the repository URL you want to clone. It can
|
490
|
-
be a *remote* repository URL (e.g., on GitHub or GitLab) or a *local path*
|
491
|
-
to a repository.
|
492
|
-
* `<directory_name>` (optional), this is the directory name where the
|
493
|
-
repository will be cloned. Git will create a new directory using the
|
494
|
-
repository's name if not specified.
|
495
|
-
|
496
|
-
|
497
|
-
[role="mt-5"]
|
498
|
-
== Commit Commands
|
499
|
-
|
500
|
-
The git `commit` command is used to record *changes* to the repository. It
|
501
|
-
creates a new *commit* that includes the changes you have made to your files.
|
502
|
-
Commits serve as *snapshots* of the repository at a specific point in time
|
503
|
-
and form the basis of the Git version control system.
|
504
|
-
|
505
|
-
Here's what each part of the command means:
|
506
|
-
|
507
|
-
* `-m <commit_message>`, this option allows you to provide a commit message
|
508
|
-
describing the commit changes made. The commit message should be concise
|
509
|
-
but informative, summarizing the purpose or nature of the changes.
|
510
|
-
|
511
|
-
Additionally, you can use various options and flags with the git commit
|
512
|
-
command to modify its behavior. Some commonly used options include:
|
513
|
-
|
514
|
-
* `-a`, automatically stages all modified files before committing.
|
515
|
-
* `-am <commit_message>`, combines the `-a` and `-m` options, allowing
|
516
|
-
you to automatically stage modified files and provide a commit message
|
517
|
-
in a *single* command.
|
518
|
-
* `-p`, interactively selects and commits changes from specific hunks within
|
519
|
-
modified files.
|
520
|
-
|
521
|
-
To make a commit, you typically follow these steps:
|
522
|
-
|
523
|
-
. Make changes to your files in the repository using any text editor or IDE.
|
524
|
-
. Use the git add command to stage the changes you want to include in the commit.
|
525
|
-
The add option tells Git which files should be part of the commit. For
|
526
|
-
example, you can use git add `.` (dot) to stage all changes in the current
|
527
|
-
directory.
|
528
|
-
. Once you have staged the changes, use the git commit command to create a
|
529
|
-
new commit. Provide a meaningful *commit message* using the `-m` option.
|
530
|
-
|
531
|
-
After executing the commit command, Git will create a new commit with your
|
532
|
-
staged changes. The commit will be assigned a *unique identifier*, a
|
533
|
-
SHA-1 hash, and added to the repository's commit *history*.
|
534
|
-
|
535
|
-
[cols="3a, 4a, 5a", options="header", width="100%", role="rtable mt-3 mb-5"]
|
536
|
-
|===
|
537
|
-
|Command |Description |Example
|
538
|
-
|
539
|
-
|`status`
|
540
|
-
|Display a list of files in your staging directory with accompanying
|
541
|
-
file status.
|
542
|
-
|
|
543
|
-
[source, sh]
|
544
|
-
----
|
545
|
-
git status
|
546
|
-
----
|
547
|
-
|
548
|
-
|`add`
|
549
|
-
|Stage file changes. Running this command with an associated file name
|
550
|
-
will stage the file changes to your staging directory.
|
551
|
-
| Commit *all* files iin the *current* folder indicazed by `.` (dot)
|
552
|
-
[source, sh]
|
553
|
-
----
|
554
|
-
git add .
|
555
|
-
----
|
556
|
-
|
557
|
-
|`commit`
|
558
|
-
|Save changes to your Git repository. Running this command with an
|
559
|
-
associated file name will save the file changes to your repo.
|
560
|
-
|
|
561
|
-
[source, sh]
|
562
|
-
----
|
563
|
-
git commit
|
564
|
-
----
|
565
|
-
|
566
|
-
|`commit -a`
|
567
|
-
|Add all modified and deleted files in your working directory to the
|
568
|
-
current commit.
|
569
|
-
|
|
570
|
-
[source, sh]
|
571
|
-
----
|
572
|
-
git commit -a
|
573
|
-
----
|
574
|
-
|
575
|
-
|`commit --amend -m "New commit message"`
|
576
|
-
|Amend a Git commit. Edit a Git commit message by adding a message in
|
577
|
-
quotation marks after the command.
|
578
|
-
|
|
579
|
-
[source, sh]
|
580
|
-
----
|
581
|
-
commit --amend -m "New commit message"
|
582
|
-
----
|
583
|
-
|
584
|
-
|`commit -m "message text"`
|
585
|
-
|Add a Git commit message. Add your message in quotation marks
|
586
|
-
following the command.
|
587
|
-
|
|
588
|
-
[source, sh]
|
589
|
-
----
|
590
|
-
git commit -m "message text"
|
591
|
-
----
|
592
|
-
|
593
|
-
|`commit -am "message text"`
|
594
|
-
|Combine options `a` and `m` to add all modified and deleted files and
|
595
|
-
provide a commit message in a *single* command.
|
596
|
-
|
|
597
|
-
[source, sh]
|
598
|
-
----
|
599
|
-
git commit -am "message text"
|
600
|
-
----
|
601
|
-
|
602
|
-
|===
|
603
|
-
|
604
|
-
|
605
|
-
== Config Commands
|
606
|
-
|
607
|
-
Git config commands configure various aspects of Git, such as user
|
608
|
-
information, default behavior, aliases, etc. Here are some commonly
|
609
|
-
used Git config commands:
|
610
|
-
|
611
|
-
[cols="3a, 4a, 5a", options="header", width="100%", role="rtable mt-3 mb-5"]
|
612
|
-
|===
|
613
|
-
|Command |Description |Example
|
614
|
-
|
615
|
-
|`config --global user.email "email@address"`
|
616
|
-
|Sets the *email address* associated with your Git commits and
|
617
|
-
other Git actions.
|
618
|
-
|
|
619
|
-
[source, sh]
|
620
|
-
----
|
621
|
-
git config --global user.email "my@mail.address"
|
622
|
-
----
|
623
|
-
|
624
|
-
|`config --global user.name "name"`
|
625
|
-
|Sets the *user name* associated with your Git commits and other
|
626
|
-
Git actions.
|
627
|
-
|
|
628
|
-
[source, sh]
|
629
|
-
----
|
630
|
-
git config --global user.name "My Name"
|
631
|
-
----
|
632
|
-
|
633
|
-
|`config --global core.editor "editor"`
|
634
|
-
|Sets the text editor Git should use when creating commit messages.
|
635
|
-
Replace [editor] with your preferred text editor (e.g., "vim," "nano,"
|
636
|
-
"subl" for Sublime Text). On *Windows*, set the *path* to your
|
637
|
-
preferred editor like `C:/Program Files (x86)/Notepad++/notepad++.exe`.
|
638
|
-
|
|
639
|
-
[source, sh]
|
640
|
-
----
|
641
|
-
git config --global core.editor "vim"
|
642
|
-
----
|
643
|
-
|
644
|
-
|`config --list`
|
645
|
-
|Lists *all* the Git configuration settings currently set on your system.
|
646
|
-
|
|
647
|
-
[source, sh]
|
648
|
-
----
|
649
|
-
git config --list
|
650
|
-
----
|
651
|
-
|
652
|
-
|`config --local --edit`
|
653
|
-
|Opens the Git configuration file fron the current *repo* (`.git/config`)
|
654
|
-
in the default text editor, allowing you to *manually* edit the settings.
|
655
|
-
|
|
656
|
-
[source, sh]
|
657
|
-
----
|
658
|
-
git config --local --edit
|
659
|
-
----
|
660
|
-
|
661
|
-
|`config --global --edit`
|
662
|
-
|Opens your *personal* Git configuration file (`~/.gitconfig`) from the
|
663
|
-
*home* directory in the default text editor, allowing you to *manually*
|
664
|
-
edit the settings.
|
665
|
-
|
|
666
|
-
[source, sh]
|
667
|
-
----
|
668
|
-
git config --global --edit
|
669
|
-
----
|
670
|
-
|
671
|
-
|`config --system --edit`
|
672
|
-
|Opens the Git *application* configuration file (`<Git folder>/etc/gitconfig`)
|
673
|
-
in the default text editor, allowing you to *manually* edit the settings.
|
674
|
-
|
|
675
|
-
[source, sh]
|
676
|
-
----
|
677
|
-
git config --system --edit
|
678
|
-
----
|
679
|
-
|
680
|
-
|===
|
681
|
-
|
682
|
-
|
683
|
-
[role="mt-5"]
|
684
|
-
== Merge Commands
|
685
|
-
|
686
|
-
When using Git, several commands are available to perform a merge operation.
|
687
|
-
The most commonly used commands for merging branches are `git merge` and
|
688
|
-
`git pull` (see <<Pull Commands>>).
|
689
|
-
|
690
|
-
Here's an overview of these commands:
|
691
|
-
|
692
|
-
[cols="3a, 4a, 5a", options="header", width="100%", role="rtable mt-3 mb-3"]
|
693
|
-
|===
|
694
|
-
|Command |Description |Example
|
695
|
-
|
696
|
-
|`merge`
|
697
|
-
|Combine two or more development histories together. Used in
|
698
|
-
combination with fetch, this will combine the fetched history
|
699
|
-
from a remote branch into the currently checked out local branch.
|
700
|
-
|
|
701
|
-
[source, sh]
|
702
|
-
----
|
703
|
-
git merge
|
704
|
-
----
|
705
|
-
|
706
|
-
|`merge <branch-name>`
|
707
|
-
|Merge changes from one branch into the branch you currently
|
708
|
-
have checked out.
|
709
|
-
|
|
710
|
-
[source, sh]
|
711
|
-
----
|
712
|
-
git merge develop
|
713
|
-
----
|
714
|
-
|
715
|
-
|`merge --abort`
|
716
|
-
|Aborts the merge process and restores project’s state
|
717
|
-
to before the merge was attempted. This works as a failsafe when
|
718
|
-
a conflict occurs.
|
719
|
-
|
|
720
|
-
[source, sh]
|
721
|
-
----
|
722
|
-
git merge --abort develop
|
723
|
-
----
|
724
|
-
|
725
|
-
|`merge --continue`
|
726
|
-
|Attempt to complete a merge that was stopped due to file conflicts
|
727
|
-
after *resolving* the merge *conflict*.
|
728
|
-
|
|
729
|
-
[source, sh]
|
730
|
-
----
|
731
|
-
git merge --continue develop
|
732
|
-
----
|
733
|
-
|
734
|
-
|`merge --squash`
|
735
|
-
|Combine all changes from the branch being merged into a single
|
736
|
-
commit rather than preserving them as individual commits.
|
737
|
-
|
|
738
|
-
[source, sh]
|
739
|
-
----
|
740
|
-
git merge --squash
|
741
|
-
----
|
742
|
-
|
743
|
-
|`merge --no-commit`
|
744
|
-
|Combine branch into the current branch, but do not make a new commit.
|
745
|
-
|
|
746
|
-
[source, sh]
|
747
|
-
----
|
748
|
-
git merge --no-commit develop
|
749
|
-
----
|
750
|
-
|
751
|
-
|`merge --no-ff`
|
752
|
-
|Creates a merge commit instead of attempting a *fast-forward*.
|
753
|
-
|
|
754
|
-
[source, sh]
|
755
|
-
----
|
756
|
-
git merge --no-ff develop
|
757
|
-
----
|
758
|
-
|
759
|
-
|===
|
760
|
-
|
761
|
-
TIP: These are the basic commands for merging branches in Git. Additionally,
|
762
|
-
you can use some more options and flags with these commands to modify their
|
763
|
-
behavior. I recommend consulting the Git documentation for a more comprehensive
|
764
|
-
understanding of the available options and scenarios where merging can be
|
765
|
-
used effectively.
|
766
|
-
|
767
|
-
|
768
|
-
[role="mt-5"]
|
769
|
-
== Pull Commands
|
770
|
-
|
771
|
-
The `git pull` command *fetches* and *merges* changes from a remote repository
|
772
|
-
into the *current branch*. Here's an overview of the `pull` command and
|
773
|
-
its commonly used options:
|
774
|
-
|
775
|
-
[cols="3a, 4a, 5a", options="header", width="100%", role="rtable mt-3 mb-3"]
|
776
|
-
|===
|
777
|
-
|Command |Description |Example
|
778
|
-
|
779
|
-
|`pull`
|
780
|
-
|This command fetches, and merges changes from the *remote* repository into
|
781
|
-
your current *local* branch.
|
782
|
-
|
|
783
|
-
[source, sh]
|
784
|
-
----
|
785
|
-
git pull
|
786
|
-
----
|
787
|
-
|
788
|
-
|`pull --quiet`
|
789
|
-
|Suppress the output text after both `git fetch` and `git merge`.
|
790
|
-
|
|
791
|
-
[source, sh]
|
792
|
-
----
|
793
|
-
git pull --quiet
|
794
|
-
----
|
795
|
-
|`pull --verbose`
|
796
|
-
|Expand the output text after both `git fetch` and `git merge`.
|
797
|
-
|
|
798
|
-
[source, sh]
|
799
|
-
----
|
800
|
-
git pull --verbose
|
801
|
-
----
|
802
|
-
|
803
|
-
|===
|
804
|
-
|
805
|
-
=== Commands related to a `merge`
|
806
|
-
|
807
|
-
When performing a `git pull` command, you typically *fetch and merge* the
|
808
|
-
latest changes from a remote repository into your current branch. Here
|
809
|
-
are some common scenarios related to merging during a `pull`:
|
810
|
-
|
811
|
-
* `git pull --squash` – Combine all changes from the branch being
|
812
|
-
merged into a single commit, rather than preserving the individual
|
813
|
-
commits.
|
814
|
-
* `git pull --no-commit` – Combine the currently checked out
|
815
|
-
branch with the remote upstream branch.
|
816
|
-
* `git pull --no-ff` – Create a merge commit in all cases, even
|
817
|
-
when the merge could instead be resolved as a fast-forward.
|
818
|
-
|
819
|
-
=== Commands related to a `fetch`
|
820
|
-
|
821
|
-
When using Git, the `git pull` command *fetches and merges* changes from a
|
822
|
-
remote repository into your local repository. It combines the `git fetch`
|
823
|
-
command (to retrieve the latest changes from the remote repository) with
|
824
|
-
the `git merge` command (to incorporate those changes into your local branch).
|
825
|
-
|
826
|
-
Here are some `git pull` commands and related options you can use in
|
827
|
-
different scenarios:
|
828
|
-
|
829
|
-
* `git pull --all` – Fetch all remotes.
|
830
|
-
* `git pull --depth=<depth>` – Fetch a limited number of commits.
|
831
|
-
* `git pull --dry-run` – Show the action that would be completed
|
832
|
-
without actually making changes to your repo.
|
833
|
-
* `git pull --prune` – Remove all remote references that no longer
|
834
|
-
exist on the remote.
|
835
|
-
* `git pull --no-tags` – Do not fetch tags.
|
836
|
-
|
837
|
-
|
838
|
-
[role="mt-5"]
|
839
|
-
== Push Commands
|
840
|
-
|
841
|
-
The `git push` command *uploads* local repository commits to a *remote*
|
842
|
-
repository. It is used to share your changes with others or to update
|
843
|
-
a remote repository with your latest work. Here's an overview of the `push`
|
844
|
-
command and its commonly used options:
|
845
|
-
|
846
|
-
[cols="3a, 4a, 5a", options="header", width="100%", role="rtable mt-3 mb-3"]
|
847
|
-
|===
|
848
|
-
|Command |Description |Example
|
849
|
-
|
850
|
-
|`push`
|
851
|
-
|Push the current checked out branch to the *default* remote `origin`.
|
852
|
-
|
|
853
|
-
[source, sh]
|
854
|
-
----
|
855
|
-
git push
|
856
|
-
----
|
857
|
-
|
858
|
-
|`push <remote> <branch>`
|
859
|
-
|Push the specified *local* branch along with all of its necessary commits
|
860
|
-
to your destination *remote* repository.
|
861
|
-
|
|
862
|
-
[source, sh]
|
863
|
-
----
|
864
|
-
git push origin main
|
865
|
-
----
|
866
|
-
|
867
|
-
|`push <remote> --force`
|
868
|
-
|Force a Git push in a non-fast-forward merge. This option forces
|
869
|
-
the update of a remote ref even when that is not the ancestor of the
|
870
|
-
local ref. This can cause the remote repository to loose commits,
|
871
|
-
so use with care.
|
872
|
-
|
|
873
|
-
[source, sh]
|
874
|
-
----
|
875
|
-
git push <remote> --force
|
876
|
-
----
|
877
|
-
|
878
|
-
|`push <remote> --all`
|
879
|
-
|Push *all* local branches to a specified remote.
|
880
|
-
|
|
881
|
-
[source, sh]
|
882
|
-
----
|
883
|
-
git push <remote> --all
|
884
|
-
----
|
885
|
-
|
886
|
-
|`git push <remote> --tags`
|
887
|
-
|Push all local tags to a specified remote (can ommitted for *default* remote).
|
888
|
-
Note that tags are *not* automatically sent when using `--all`.
|
889
|
-
|
|
890
|
-
[source, sh]
|
891
|
-
----
|
892
|
-
git push origin --tags
|
893
|
-
----
|
894
|
-
|
895
|
-
|===
|
896
|
-
|
897
|
-
|
898
|
-
[role="mt-5"]
|
899
|
-
== Rebase Commands
|
900
|
-
|
901
|
-
The `git rebase` command that integrates changes from one branch onto
|
902
|
-
another. It allows you to modify the *commit history* of a branch by
|
903
|
-
moving, combining, or deleting commits.
|
904
|
-
|
905
|
-
Here are some commonly used Git rebase commands:
|
906
|
-
|
907
|
-
[cols="3a, 4a, 5a", options="header", width="100%", role="rtable mt-3 mb-3"]
|
908
|
-
|===
|
909
|
-
|Command |Description |Example
|
910
|
-
|
911
|
-
|`rebase <target branch name>`
|
912
|
-
|Rebase your currently checked out branch onto a target branch.
|
913
|
-
This rewrites a commit(s) from the source branch and applies it on
|
914
|
-
the top of the target branch.
|
915
|
-
|
|
916
|
-
[source, sh]
|
917
|
-
----
|
918
|
-
git rebase <target branch name>
|
919
|
-
----
|
920
|
-
|
921
|
-
|`rebase --continue`
|
922
|
-
|Proceed with a Git rebase after you have resolved a conflict
|
923
|
-
between files.
|
924
|
-
|
|
925
|
-
[source, sh]
|
926
|
-
----
|
927
|
-
git rebase --continue
|
928
|
-
----
|
929
|
-
|
930
|
-
|`rebase --skip`
|
931
|
-
|Skip an action that results in a conflict to proceed with a Git rebase.
|
932
|
-
|
|
933
|
-
[source, sh]
|
934
|
-
----
|
935
|
-
git rebase --skip
|
936
|
-
----
|
937
|
-
|
938
|
-
|`rebase --abort`
|
939
|
-
|Cancel a Git rebase. Your branch will be back in the state it was
|
940
|
-
before you started the rebase.
|
941
|
-
|
|
942
|
-
[source, sh]
|
943
|
-
----
|
944
|
-
git rebase --abort
|
945
|
-
----
|
946
|
-
|
947
|
-
|`rebase <target branch name> -i`
|
948
|
-
|Initiate interactive rebase from your currently checked
|
949
|
-
out branch onto a target branch.
|
950
|
-
|
|
951
|
-
[source, sh]
|
952
|
-
----
|
953
|
-
git rebase <target branch name> -i
|
954
|
-
----
|
955
|
-
|
956
|
-
|===
|
957
|
-
|
958
|
-
CAUTION: The command `rebase` is a flexible way to *manipulate* the commit
|
959
|
-
*history*. Still, it's important to use it *cautiously*, especially when
|
960
|
-
working on *shared* branches (like the *main* branch), as it rewrite the
|
961
|
-
commit history and potentially cause issues for other collaborators.
|
962
|
-
|
963
|
-
|
964
|
-
[role="mt-5"]
|
965
|
-
== Stash Commands
|
966
|
-
|
967
|
-
Git stash is a command that *temporarily* saves *changes* you have made to
|
968
|
-
your working directory so that you can switch to a different branch or
|
969
|
-
apply the changes *later*.
|
970
|
-
|
971
|
-
Here are some commonly used stash commands:
|
972
|
-
|
973
|
-
[cols="3a, 4a, 5a", options="header", width="100%", role="rtable mt-3 mb-3"]
|
974
|
-
|===
|
975
|
-
|Command |Description |Example
|
976
|
-
|
977
|
-
|`stash`
|
978
|
-
|Create a stash with local modifications and revert back to the head commit.
|
979
|
-
|
|
980
|
-
[source, sh]
|
981
|
-
----
|
982
|
-
git stash
|
983
|
-
----
|
984
|
-
|
985
|
-
|`stash list`
|
986
|
-
|Display a list of all stashes in your repository.
|
987
|
-
|
|
988
|
-
[source, sh]
|
989
|
-
----
|
990
|
-
git stash list
|
991
|
-
----
|
992
|
-
|
993
|
-
|`stash show`
|
994
|
-
|View the content of your most recent stash. This will show your
|
995
|
-
stashed changes as a diff between the stashed content and the commit
|
996
|
-
from back when the stash was created.
|
997
|
-
|
|
998
|
-
[source, sh]
|
999
|
-
----
|
1000
|
-
git stash show
|
1001
|
-
----
|
1002
|
-
|
1003
|
-
|`stash drop <stash>`
|
1004
|
-
|Remove a stash from the list of stashes in your repository.
|
1005
|
-
|
|
1006
|
-
[source, sh]
|
1007
|
-
----
|
1008
|
-
git stash drop <stash>
|
1009
|
-
----
|
1010
|
-
|
1011
|
-
|`stash pop <stash>`
|
1012
|
-
|Apply a stash to the top of the current working tree and remove
|
1013
|
-
it from your list of stashes.
|
1014
|
-
|
|
1015
|
-
[source, sh]
|
1016
|
-
----
|
1017
|
-
git stash pop <stash>
|
1018
|
-
----
|
1019
|
-
|
1020
|
-
|`stash apply <stash>`
|
1021
|
-
|Apply a stash on top of the current working tree. The stash
|
1022
|
-
will not be removed from your list of stashes.
|
1023
|
-
|
|
1024
|
-
[source, sh]
|
1025
|
-
----
|
1026
|
-
git stash apply <stash>
|
1027
|
-
----
|
1028
|
-
|
1029
|
-
|`stash clear`
|
1030
|
-
|Remove all stashes from your repository.
|
1031
|
-
|
|
1032
|
-
[source, sh]
|
1033
|
-
----
|
1034
|
-
git stash clear
|
1035
|
-
----
|
1036
|
-
|
1037
|
-
|===
|
1038
|
-
|
1039
|
-
TIP: Stashing is useful when *switching* branches or *temporarily*
|
1040
|
-
setting aside your changes *without committing* them. It allows you to
|
1041
|
-
work on different tasks or switch contexts without losing your current work.
|
1042
|
-
|
1043
|
-
|
1044
|
-
[role="mt-5"]
|
1045
|
-
== Common commands
|
1046
|
-
|
1047
|
-
Find some already *prepared* Git commands used quite often.
|
1048
|
-
|
1049
|
-
=== Clearing the index
|
1050
|
-
|
1051
|
-
The commands below will *remove* all of the items from the Git *index* (not
|
1052
|
-
from the *working directory* or local repo) and then (re-)update from
|
1053
|
-
local folder `.`.
|
1054
|
-
|
1055
|
-
.Clear the index and re-add all files
|
1056
|
-
[source, sh]
|
1057
|
-
----
|
1058
|
-
git rm -r --cached . && git add .
|
1059
|
-
----
|
1060
|
-
|
1061
|
-
or forced
|
1062
|
-
|
1063
|
-
.Clear the index forced and re-add all files
|
1064
|
-
[source, sh]
|
1065
|
-
----
|
1066
|
-
git rm -rf --cached . && git add .
|
1067
|
-
----
|
1068
|
-
|
1069
|
-
=== Commit commands
|
1070
|
-
|
1071
|
-
[cols="3a, 4a, 5a", options="header", width="100%", role="rtable mt-3 mb-3"]
|
1072
|
-
|===
|
1073
|
-
|Command |Description |Example
|
1074
|
-
|
1075
|
-
|`commit -am "Cleanup files"`
|
1076
|
-
|Commit when files are *cleaned*. *No* files are changed but some *deleted*.
|
1077
|
-
|
|
1078
|
-
[source, sh]
|
1079
|
-
----
|
1080
|
-
git commit -am "Cleanup files"
|
1081
|
-
----
|
1082
|
-
|
1083
|
-
|`commit -am "New version 2023.4.2"`
|
1084
|
-
|Commit a specific *version*.
|
1085
|
-
|
|
1086
|
-
[source, sh]
|
1087
|
-
----
|
1088
|
-
git commit -am "New version 2023.4.2"
|
1089
|
-
----
|
1090
|
-
|
1091
|
-
|`commit --allow-empty -m "New version 2023.4.2"`
|
1092
|
-
|Commit a specific version but *no* (file) changes applied.
|
1093
|
-
|
|
1094
|
-
[source, sh]
|
1095
|
-
----
|
1096
|
-
git commit --allow-empty -m "New version 2023.4.2"
|
1097
|
-
----
|
1098
|
-
|
1099
|
-
|`commit -am "Prepare new version 2023.4.2"`
|
1100
|
-
|Commit a specific version but changes are *not* final.
|
1101
|
-
|
|
1102
|
-
[source, sh]
|
1103
|
-
----
|
1104
|
-
git commit -am "Prepare new version 2023.4.2"
|
1105
|
-
----
|
1106
|
-
|
1107
|
-
|`commit -am "Latest files"`
|
1108
|
-
|Commit latest changes but *no* specific reason given.
|
1109
|
-
|
|
1110
|
-
[source, sh]
|
1111
|
-
----
|
1112
|
-
git commit -am "Latest files"
|
1113
|
-
----
|
1114
|
-
|
1115
|
-
|===
|
1116
|
-
|
1117
|
-
=== Create a new repository on the command line
|
1118
|
-
|
1119
|
-
[source, sh]
|
1120
|
-
----
|
1121
|
-
echo "# Heroku starter_app" >> README.md
|
1122
|
-
git init
|
1123
|
-
git add README.md
|
1124
|
-
git commit -m "initial commit"
|
1125
|
-
|
1126
|
-
git remote add origin https://github.com/jekyll-one-org/my_heroku_starter_app.git
|
1127
|
-
git push -u origin main
|
1128
|
-
----
|
1129
|
-
|
1130
|
-
|
1131
|
-
=== Add file permissions on Windows
|
1132
|
-
|
1133
|
-
Change file permissions *Unix-style* (chmod) when are on Windows. This may
|
1134
|
-
helpful when shell scripts are created and *execute* rights are required
|
1135
|
-
to be stored in the *repo*.
|
1136
|
-
|
1137
|
-
[source, sh]
|
1138
|
-
----
|
1139
|
-
git update-index --chmod=+x 'name-of-shell-script'
|
1140
|
-
----
|
1141
|
-
|
1142
|
-
NOTE: See for more details on
|
1143
|
-
https://medium.com/@akash1233/change-file-permissions-when-working-with-git-repos-on-windows-ea22e34d5cee[Change file permissions when working on windows, {browser-window--new}]
|
1144
|
-
|
1145
|
-
=== Disable warning `CRLF will be replaced by LF`
|
1146
|
-
|
1147
|
-
You can turn off the warning with:
|
1148
|
-
|
1149
|
-
[source, sh]
|
1150
|
-
----
|
1151
|
-
git config --global core.safecrlf false
|
1152
|
-
----
|
1153
|
-
|
1154
|
-
NOTE: This will only turn off the warning, not the *function* itself.
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
////
|
1160
|
-
== Make a new commit and create a new message
|
1161
|
-
|
1162
|
-
Make a new commit and create a new message if no changes are made to files
|
1163
|
-
|
1164
|
-
[source, sh]
|
1165
|
-
----
|
1166
|
-
git commit --allow-empty -m "Test on empty commit"
|
1167
|
-
----
|
1168
|
-
|
1169
|
-
== Create a new repository on the command line
|
1170
|
-
|
1171
|
-
[source, sh]
|
1172
|
-
----
|
1173
|
-
echo "# Heroku starter_app" >> README.md
|
1174
|
-
git init
|
1175
|
-
git add README.md
|
1176
|
-
git commit -m "initial commit"
|
1177
|
-
git remote add origin https://github.com/jekyll-one-org/my_heroku_starter_app.git
|
1178
|
-
git push -u origin main
|
1179
|
-
----
|
1180
|
-
|
1181
|
-
== List branches
|
1182
|
-
|
1183
|
-
git branch -a zeigt alle lokalen und entfernten Branches an, hingegen -r
|
1184
|
-
nur die entfernten Branches anzeigt.
|
1185
|
-
|
1186
|
-
[source, sh]
|
1187
|
-
----
|
1188
|
-
git branch -a
|
1189
|
-
git branch -r
|
1190
|
-
----
|
1191
|
-
|
1192
|
-
== Rename a branch
|
1193
|
-
|
1194
|
-
If you want to rename a local branch while pointed to `any` branch, do:
|
1195
|
-
|
1196
|
-
[source, sh]
|
1197
|
-
----
|
1198
|
-
git branch -m <oldname> <newname>
|
1199
|
-
----
|
1200
|
-
|
1201
|
-
If you want to rename the `current` local branch, you can do:
|
1202
|
-
|
1203
|
-
[source, sh]
|
1204
|
-
----
|
1205
|
-
git branch -m <newname>
|
1206
|
-
----
|
1207
|
-
|
1208
|
-
If you want rename a the local branch *and* push|reset the `upstream` branch:
|
1209
|
-
|
1210
|
-
[source, sh]
|
1211
|
-
----
|
1212
|
-
git push origin -u <newname>
|
1213
|
-
git push origin --delete <old_name>
|
1214
|
-
----
|
1215
|
-
|
1216
|
-
== Push current branch to remote (main)
|
1217
|
-
|
1218
|
-
[source, sh]
|
1219
|
-
----
|
1220
|
-
git push --set-upstream origin main
|
1221
|
-
----
|
1222
|
-
|
1223
|
-
|
1224
|
-
== Create branches
|
1225
|
-
|
1226
|
-
Create a branch on your local machine *and* switch in this branch:
|
1227
|
-
|
1228
|
-
[source, sh]
|
1229
|
-
----
|
1230
|
-
git checkout -b <name_of_your_new_branch>
|
1231
|
-
----
|
1232
|
-
|
1233
|
-
NOTE: Git does not allow creating a (new, isolated) branch on a remote
|
1234
|
-
repository. Instead, you can push an existing local branch and thereby
|
1235
|
-
publish it on a remote repository.
|
1236
|
-
|
1237
|
-
|
1238
|
-
== Delete branches
|
1239
|
-
|
1240
|
-
See:
|
1241
|
-
{https://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-locally-and-remotely}[Stackoverflow]
|
1242
|
-
|
1243
|
-
=== Delete branches from `remote`
|
1244
|
-
|
1245
|
-
[source, sh]
|
1246
|
-
----
|
1247
|
-
git push -d <remote_name> <branch_name>
|
1248
|
-
----
|
1249
|
-
|
1250
|
-
NOTE: In most cases the remote name is origin. In such a case you'll
|
1251
|
-
have to use the command like so.
|
1252
|
-
|
1253
|
-
[source, sh]
|
1254
|
-
----
|
1255
|
-
git push -d origin <branch_name>
|
1256
|
-
----
|
1257
|
-
|
1258
|
-
=== Delete branches from `local`
|
1259
|
-
|
1260
|
-
[source, sh]
|
1261
|
-
----
|
1262
|
-
git branch -d <branch_name>
|
1263
|
-
----
|
1264
|
-
|
1265
|
-
|
1266
|
-
== Create branch from commit
|
1267
|
-
|
1268
|
-
Create a branch from a previous `commit`:
|
1269
|
-
|
1270
|
-
[source, sh]
|
1271
|
-
----
|
1272
|
-
git branch branch_name <sha1-of-commit>
|
1273
|
-
----
|
1274
|
-
|
1275
|
-
|
1276
|
-
== Reset repo to a commit
|
1277
|
-
|
1278
|
-
=== Reset from `local`
|
1279
|
-
|
1280
|
-
[source, sh]
|
1281
|
-
----
|
1282
|
-
git reset --hard 217a618
|
1283
|
-
----
|
1284
|
-
|
1285
|
-
=== Reset from `remote`
|
1286
|
-
|
1287
|
-
[source, sh]
|
1288
|
-
----
|
1289
|
-
git push --force origin main
|
1290
|
-
----
|
1291
|
-
|
1292
|
-
|
1293
|
-
== Push an existing repository from the command line
|
1294
|
-
|
1295
|
-
[source, sh]
|
1296
|
-
----
|
1297
|
-
git remote add github https://github.com/jekyll-one-org/heroku_starter_app.git
|
1298
|
-
git push -u github main
|
1299
|
-
----
|
1300
|
-
|
1301
|
-
|
1302
|
-
== Removing non-repository files with git
|
1303
|
-
|
1304
|
-
See: https://stackoverflow.com/questions/5037480/removing-non-repository-files-with-git
|
1305
|
-
|
1306
|
-
If you want to see which files will be deleted you can use the
|
1307
|
-
option -n *before* you run the actual command:
|
1308
|
-
|
1309
|
-
[source, sh]
|
1310
|
-
----
|
1311
|
-
git clean -n
|
1312
|
-
----
|
1313
|
-
|
1314
|
-
You can use git-clean. This command will remove untracked files/directories.
|
1315
|
-
By default, it will only print what it would have removed, without actually
|
1316
|
-
removing them.
|
1317
|
-
|
1318
|
-
Given the -f flag to remove the files, and the -d flag to remove empty
|
1319
|
-
directories as well:
|
1320
|
-
|
1321
|
-
[source, sh]
|
1322
|
-
----
|
1323
|
-
git clean -df
|
1324
|
-
----
|
1325
|
-
|
1326
|
-
Also removing ignored files:
|
1327
|
-
|
1328
|
-
[source, sh]
|
1329
|
-
----
|
1330
|
-
git clean -dfx
|
1331
|
-
----
|
1332
|
-
|
1333
|
-
|
1334
|
-
== Modify most recent commit message
|
1335
|
-
|
1336
|
-
The git commit option `--amend` allows you to change the *most recent*
|
1337
|
-
commit message:
|
1338
|
-
|
1339
|
-
[source, sh]
|
1340
|
-
----
|
1341
|
-
git commit --amend -m "New commit message"
|
1342
|
-
----
|
1343
|
-
|
1344
|
-
|
1345
|
-
== Delete a Git tag
|
1346
|
-
|
1347
|
-
Use the git 'tag' command with the '-d' option
|
1348
|
-
|
1349
|
-
.from local
|
1350
|
-
|
1351
|
-
[source, sh]
|
1352
|
-
----
|
1353
|
-
git tag -d v2023.4.2
|
1354
|
-
----
|
1355
|
-
|
1356
|
-
.from remote
|
1357
|
-
|
1358
|
-
[source, sh]
|
1359
|
-
----
|
1360
|
-
git push -d origin v2023.4.2
|
1361
|
-
----
|
1362
|
-
|
1363
|
-
|
1364
|
-
== Set a Git tag
|
1365
|
-
|
1366
|
-
When modifying remember to issue a new tag command in git before committing,
|
1367
|
-
then push the new tag
|
1368
|
-
|
1369
|
-
[source, sh]
|
1370
|
-
----
|
1371
|
-
git tag -a v2023.4.2 -m "v2023.4.2"
|
1372
|
-
git push origin --tags
|
1373
|
-
----
|
1374
|
-
|
1375
|
-
|
1376
|
-
== Update Git Index (cache) completely
|
1377
|
-
|
1378
|
-
See: https://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore
|
1379
|
-
|
1380
|
-
The series of commands below will remove all of the items from the Git
|
1381
|
-
Index (not from the working directory or local repo), and then updates
|
1382
|
-
the Git Index, while respecting git ignores.
|
1383
|
-
|
1384
|
-
NOTE: Index = Cache
|
1385
|
-
|
1386
|
-
[source, sh]
|
1387
|
-
----
|
1388
|
-
git rm -r --cached . && git add .
|
1389
|
-
----
|
1390
|
-
|
1391
|
-
or forced
|
1392
|
-
|
1393
|
-
[source, sh]
|
1394
|
-
----
|
1395
|
-
git rm -rf --cached . && git add .
|
1396
|
-
----
|
1397
|
-
|
1398
|
-
Then:
|
1399
|
-
|
1400
|
-
[source, sh]
|
1401
|
-
----
|
1402
|
-
git commit -am "Cleanup files"
|
1403
|
-
git commit -am "New version 2023.4.2"
|
1404
|
-
git commit --allow-empty -m "New version 2023.4.2"
|
1405
|
-
git commit -am "Prepare new version 2023.4.2"
|
1406
|
-
git commit -am "Latest files of version 2023.4.2"
|
1407
|
-
----
|
1408
|
-
|
1409
|
-
|
1410
|
-
== Add file permissions on Windows
|
1411
|
-
|
1412
|
-
See: https://medium.com/@akash1233/change-file-permissions-when-working-with-git-repos-on-windows-ea22e34d5cee
|
1413
|
-
|
1414
|
-
Most of the folks on Windows working with git repo’s use windows git bash
|
1415
|
-
for doing git check-ins and check-outs to/from from git repo…. if you are
|
1416
|
-
already not using it i will highly recommend use it… pretty neat tool
|
1417
|
-
for windows os.
|
1418
|
-
|
1419
|
-
[source, sh]
|
1420
|
-
----
|
1421
|
-
git update-index --chmod=+x 'name-of-shell-script'
|
1422
|
-
----
|
1423
|
-
|
1424
|
-
|
1425
|
-
== List all committed files
|
1426
|
-
|
1427
|
-
List all files in the repo, including those that are only staged but not
|
1428
|
-
yet committed:
|
1429
|
-
|
1430
|
-
[source, sh]
|
1431
|
-
----
|
1432
|
-
git ls-files
|
1433
|
-
----
|
1434
|
-
|
1435
|
-
Lists all of the *already* committed files being tracked by the repo:
|
1436
|
-
|
1437
|
-
[source, sh]
|
1438
|
-
----
|
1439
|
-
git ls-tree --full-tree -r --name-only HEAD
|
1440
|
-
----
|
1441
|
-
|
1442
|
-
|
1443
|
-
== Disable warning `CRLF will be replaced by LF`
|
1444
|
-
|
1445
|
-
You can turn off the warning with:
|
1446
|
-
|
1447
|
-
[source, sh]
|
1448
|
-
----
|
1449
|
-
git config --global core.safecrlf false
|
1450
|
-
----
|
1451
|
-
|
1452
|
-
NOTE: This will only turn off the warning, not the function itself.
|
1453
|
-
|
1454
|
-
|
1455
|
-
== Upload Gem to Gemfury
|
1456
|
-
|
1457
|
-
[source, sh]
|
1458
|
-
----
|
1459
|
-
git remote add fury https://jekyll-one@git.fury.io/jekyll-one-org/<package-name>.git
|
1460
|
-
git push fury master
|
1461
|
-
----
|
1462
|
-
////
|