13
13
# TODO: Get a version that works on Windows
14
14
15
15
TMP=' git-sample-repo'
16
- clear
16
+ # clear
17
+ echo " "
18
+ echo " "
19
+ echo " "
20
+ echo " "
21
+ echo " "
17
22
# Make the beginning of run easy to find:
18
23
echo " **********************************************************"
19
24
echo " ******** STEP Delete \" $TMP \" remnant from previous run:"
@@ -22,7 +27,9 @@ mkdir ${TMP}
22
27
cd ${TMP}
23
28
24
29
echo " ******** Git version :"
30
+ # After "brew install git" on Mac:
25
31
git --version
32
+
26
33
echo " ******** STEP Init repo :"
27
34
# init without --bare so we get a working directory:
28
35
git init
@@ -45,12 +52,15 @@ echo $DEFAULT_BRANCH
45
52
# git config branch.develop.remote origin
46
53
# git config branch.develop.merge refs/heads/develop
47
54
48
- echo " ******** STEP Config:"
55
+ echo " ******** STEP Config (not --global) :"
49
56
# See https://git-scm.com/docs/pretty-formats :
50
57
git config user.name " Wilson Mar"
51
58
git config user.email
" [email protected] "
52
- # echo "$GIT_COMMITTER_EMAIL=" $GIT_COMMITTER_EMAIL
53
59
# echo $GIT_AUTHOR_EMAIL
60
+ # echo $GIT_COMMITTER_EMAIL
61
+ # gpg --list-keys
62
+ git config --global user.signingkey 2E23C648
63
+
54
64
# Verify settings:
55
65
git config core.filemode false
56
66
@@ -64,35 +74,38 @@ git config core.editor "~/Sublime\ Text\ 3/sublime_text -w"
64
74
git config color.ui auto
65
75
66
76
# See https://git-scm.com/docs/pretty-formats :
77
+ # In Windows, double quotes are needed:
67
78
git config alias.l " log --pretty='%Cred%h%Creset %C(yellow)%d%Creset | %Cblue%s%Creset' --graph"
79
+
68
80
git config alias.s " status -s"
69
81
# it config alias.w "show -s --quiet --pretty=format:'%Cred%h%Creset | %Cblue%s%Creset | (%cr) %Cgreen<%ae>%Creset'"
70
- git config alias.w " show -s --quiet --pretty=format:'%Cred%h%Creset | %Cblue%s%Creset'"
82
+ git config alias.w " show -s --quiet --pretty=format:'%Cred%h%Creset | %Cblue%s%Creset' %G? "
71
83
git config alias.ca " commit -a --amend -C HEAD"
72
84
73
85
# Have git diff use mnemonic prefixes (index, work tree, commit, object) instead of standard a and b notation:
74
86
git config diff.mnemonicprefix true
87
+
88
+ # Reuse recorded resolution of conflicted merges - https://git-scm.com/docs/git-rerere
75
89
git config rerere.enabled false
76
90
77
- # Dump config file:
78
- # git config --list
91
+ # git config --list # Dump config file
79
92
80
- echo " ******** STEP commit a1 - README.md :"
93
+ echo " ******** STEP commit (initial) README :"
81
94
touch README.md
82
95
git add .
83
- git commit -m " Add README.md"
96
+ git commit -m " README.md"
84
97
git l -1
85
98
86
- echo " ******** STEP ammend commit a2 : "
99
+ echo " ******** STEP amend commit README : "
87
100
# ammend last commit with all uncommitted and un-staged changes:
88
101
echo " some more" >> README.md
89
102
# Instead of git commit -a --amend -C HEAD
90
103
git ca # use this alias instead.
91
104
git l -1
92
105
93
- echo " ******** STEP ammend commit a3 : "
106
+ echo " ******** STEP amend commit 2 : "
94
107
# ammend last commit with all uncommitted and un-staged changes:
95
- echo " still some more" >> README.md
108
+ echo " still more" >> README.md
96
109
# Instead of git commit -a --amend -C HEAD
97
110
git ca # use this alias instead.
98
111
git l -1
@@ -106,9 +119,18 @@ git reflog
106
119
ls -al
107
120
cat README.md
108
121
109
- echo " ******** STEP tag & commit branch F1 : --------------------------"
110
- git tag v1
111
- git checkout v1 -b F1
122
+ echo " ******** STEP tag :"
123
+ # git tag v1 -m"v1 unsigned"
124
+ git tag v1 -m" v1 signed" -s
125
+ # echo "******** STEP tag verify :"
126
+ # git tag -v v1
127
+ git verify-tag v1
128
+
129
+ # echo "******** STEP tag show :"
130
+ # git show v1 # Press q to exit scroll.
131
+
132
+ echo " ******** STEP checkout feature1 branch : --------------------------"
133
+ git checkout v1 -b feature1
112
134
# git branch
113
135
ls .git/refs/heads/
114
136
git l -1
@@ -127,34 +149,35 @@ git commit -m "Add d"
127
149
git l -1
128
150
ls -al
129
151
130
- echo " ******** STEP Merge F1 :"
152
+ echo " ******** STEP Merge feature1 :"
131
153
# Instead of git checkout $DEFAULT_BRANCH :
132
154
git checkout @{-1} # checkout previous branch (develop, master)
133
155
134
- git merge F1 --no-ff --no-commit # to see what may happen
135
- # git merge F1 --no-ff <:q
136
- git merge F1 -m " merge F1 " --no-ff # --no-ff for "true merge".
156
+ # git merge --no-ff (no fast forward) for "true merge":
157
+ # git merge feature1 --no-ff --no-commit # to see what may happen
158
+ git merge feature1 -m " merge feature1 " --verify-signatures --no-ff
137
159
# resolve conflicts here?
138
- git commit -m " commit merge F1"
160
+ git add .
161
+ git commit -m " commit merge feature1"
139
162
git branch
140
163
git l -1
141
164
142
165
# echo "******** $NOW Remove merged branch ref :"
143
- # git branch -d F1
166
+ # git branch -d feature1
144
167
# git branch
145
168
# git l -1
146
169
147
170
echo " ******** STEP commit: e"
148
171
echo " e" >> file-e.txt
149
172
git add .
150
- git commit -m " e"
173
+ git commit -m " Add e"
151
174
git l -1
152
175
153
176
echo " ******** STEP commit: f"
154
177
echo " f" >> file-f.txt
155
178
ls -al
156
179
git add .
157
- git commit -m " f"
180
+ git commit -m " Add f"
158
181
git l -1
159
182
160
183
@@ -206,7 +229,7 @@ NOW=$(date +%Y-%m-%d:%H:%M:%S-MT)
206
229
FILENAME=$( echo ${TMP} _${NOW} .zip)
207
230
echo $FILENAME
208
231
# Commented out to avoid creating a file from each run:
209
- # git archive --format zip --output ../$FILENAME F1
232
+ # git archive --format zip --output ../$FILENAME feature1
210
233
# ls -l ../$FILENAME
211
234
212
235
@@ -223,6 +246,8 @@ ls -al
223
246
224
247
225
248
249
+ # git reset --hard feature1^
250
+
226
251
# Undo last commit, preserving local changes:
227
252
# git reset --soft HEAD~1
228
253
0 commit comments