Skip to content

Commit 9ae0052

Browse files
committed
commit amend
1 parent 04e6880 commit 9ae0052

File tree

1 file changed

+96
-51
lines changed

1 file changed

+96
-51
lines changed

git-sample-repo-create.sh

Lines changed: 96 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@ TMP='git-sample-repo'
1616
clear
1717
# Make the beginning of run easy to find:
1818
echo "**********************************************************"
19-
echo "******** STEP 01: Delete \"$TMP\" remnant from previous run:"
19+
echo "******** STEP Delete \"$TMP\" remnant from previous run:"
2020
rm -rf ${TMP}
2121
mkdir ${TMP}
2222
cd ${TMP}
2323

24+
echo "******** Git version :"
25+
git --version
2426
echo "******** STEP Init repo :"
2527
# init without --bare so we get a working directory:
2628
git init
2729
# return the .git path of the current project::
2830
git rev-parse --git-dir
29-
ls -al
3031
ls .git/
3132

3233
echo "******** STEP Make develop the default branch instead of master :"
@@ -51,8 +52,6 @@ git config user.email "[email protected]"
5152
# echo "$GIT_COMMITTER_EMAIL=" $GIT_COMMITTER_EMAIL
5253
# echo $GIT_AUTHOR_EMAIL
5354
# Verify settings:
54-
git config user.name
55-
git config user.email
5655
git config core.filemode false
5756

5857
# On Unix systems, ignore ^M symbols created by Windows:
@@ -65,92 +64,98 @@ git config core.editor "~/Sublime\ Text\ 3/sublime_text -w"
6564
git config color.ui auto
6665

6766
# See https://git-scm.com/docs/pretty-formats :
68-
git config alias.l "log --pretty='%Cred%h%Creset %C(yellow)%d%Creset | %Cblue%s%Creset | (%cr) %Cgreen<%ae>%Creset' --graph"
69-
git config alias.s "status -s"
70-
git config alias.w "show -s --quiet --pretty=format:'%Cred%h%Creset | %Cblue%s%Creset | (%cr) %Cgreen<%ae>%Creset'"
67+
git config alias.l "log --pretty='%Cred%h%Creset %C(yellow)%d%Creset | %Cblue%s%Creset' --graph"
68+
git config alias.s "status -s"
69+
#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'"
71+
git config alias.ca "commit -a --amend -C HEAD"
7172

7273
# Have git diff use mnemonic prefixes (index, work tree, commit, object) instead of standard a and b notation:
7374
git config diff.mnemonicprefix true
75+
git config rerere.enabled false
7476

7577
# Dump config file:
7678
# git config --list
7779

78-
echo "******** STEP First commit: a"
80+
echo "******** STEP commit a1 - README.md :"
7981
touch README.md
8082
git add .
81-
git commit -am "a"
82-
83-
echo "******** STEP Second commit:"
83+
git commit -m "Add README.md"
84+
git l -1
85+
86+
echo "******** STEP ammend commit a2 : "
87+
# ammend last commit with all uncommitted and un-staged changes:
88+
echo "some more">>README.md
89+
# Instead of git commit -a --amend -C HEAD
90+
git ca # use this alias instead.
91+
git l -1
92+
93+
echo "******** STEP ammend commit a3 : "
94+
# ammend last commit with all uncommitted and un-staged changes:
95+
echo "still some more">>README.md
96+
# Instead of git commit -a --amend -C HEAD
97+
git ca # use this alias instead.
98+
git l -1
99+
100+
echo "******** STEP commit b - .gitignore :"
84101
echo ".DS_Store">>.gitignore
85-
git status
86102
git add .
87-
# git status
88-
git commit -m "b"
89-
git l
103+
git commit -m "Add .gitignore"
104+
git l -1
105+
git reflog
106+
ls -al
107+
cat README.md
90108

91-
echo "******** STEP Third commit: branch F1"
109+
echo "******** STEP tag & commit branch F1 : --------------------------"
92110
git tag v1
93111
git checkout v1 -b F1
94-
git branch
95-
git l
112+
# git branch
113+
ls .git/refs/heads/
114+
git l -1
96115

97-
echo "******** STEP Fourth commit: c"
116+
echo "******** STEP Fourth commit c - LICENSE.md : "
98117
echo "MIT">>LICENSE.md
99118
git add .
100-
git commit -m "c"
101-
git l
119+
git commit -m "Add c"
120+
git l -1
102121

103122
echo "******** STEP commit: d"
104123
echo "free!">>LICENSE.md
105124
echo "d">>file-d.txt
106125
git add .
107-
git commit -m "d"
108-
git l
126+
git commit -m "Add d"
127+
git l -1
128+
ls -al
109129

110-
echo "******** STEP Merge:"
111-
git checkout $DEFAULT_BRANCH
112-
#git merge F1 --no-commit
130+
echo "******** STEP Merge F1 :"
131+
# Instead of git checkout $DEFAULT_BRANCH :
132+
git checkout @{-1} # checkout previous branch (develop, master)
133+
134+
git merge F1 --no-ff --no-commit # to see what may happen
113135
# git merge F1 --no-ff <:q
114-
git merge F1 --no-ff
115-
# Manually type ":q" to exit merge.
116-
git commit -m "merge F1"
136+
git merge F1 -m "merge F1" --no-ff # --no-ff for "true merge".
137+
# resolve conflicts here?
138+
git commit -m "commit merge F1"
117139
git branch
118-
git l
140+
git l -1
119141

120-
#echo "******** $NOW Remove Merge branch ref:"
142+
#echo "******** $NOW Remove merged branch ref :"
121143
#git branch -d F1
122144
#git branch
123-
#git l
145+
#git l -1
124146

125147
echo "******** STEP commit: e"
126148
echo "e">>file-e.txt
127149
git add .
128-
git status
129150
git commit -m "e"
130-
git l
151+
git l -1
131152

132153
echo "******** STEP commit: f"
133154
echo "f">>file-f.txt
134155
ls -al
135156
git add .
136157
git commit -m "f"
137-
138-
139-
# Undo last commit, preserving local changes:
140-
# git reset --soft HEAD~1
141-
142-
# Undo last commit, without preserving local changes:
143-
# git reset --hard HEAD~1
144-
145-
# Undo last commit, preserving local changes in index:
146-
# git reset --mixed HEAD~1
147-
148-
# Undo non-pushed commits:
149-
# git reset origin/$DEFAULT_BRANCH
150-
151-
# Reset to remote state:
152-
# git fetch origin
153-
# git reset --hard origin/$DEFAULT_BRANCH
158+
git l -1
154159

155160

156161
echo "Copy this and paste to a text edit for reference: --------------"
@@ -188,20 +193,60 @@ git w HEAD~2^2
188193
echo "******** show HEAD~2^3 :"
189194
git w HEAD~2^3
190195

196+
# exit
197+
191198
echo "******** Reflog: ---------------------------------------"
192199
git reflog
200+
ls -al
201+
202+
exit
193203

194204
echo "******** Create archive file, excluding .git directory :"
195205
NOW=$(date +%Y-%m-%d:%H:%M:%S-MT)
196206
FILENAME=$(echo ${TMP}_${NOW}.zip)
197207
echo $FILENAME
208+
# Commented out to avoid creating a file from each run:
198209
# git archive --format zip --output ../$FILENAME F1
199210
# ls -l ../$FILENAME
200211

212+
201213
echo "******** checkout c :"
202214
ls -al
215+
git show HEAD@{5}
203216
git checkout HEAD@{5}
204217
ls -al
218+
git reflog
219+
220+
echo "******** checkout previous HEAD :"
221+
git checkout HEAD
222+
ls -al
223+
224+
225+
226+
# Undo last commit, preserving local changes:
227+
# git reset --soft HEAD~1
228+
229+
# Undo last commit, without preserving local changes:
230+
# git reset --hard HEAD~1
231+
232+
# Undo last commit, preserving local changes in index:
233+
# git reset --mixed HEAD~1
234+
235+
# Undo non-pushed commits:
236+
# git reset origin/$DEFAULT_BRANCH
237+
238+
239+
# git stash save "text message here"
240+
# git stash list /* shows whats in stash */
241+
# git stash show -p stash@{0} /* Show the diff in the stash */
242+
# git stash pop stash@{0} /* restores the stash deletes the tash */
243+
# git stash apply stash@{0} /* restores the stash and keeps the stash */
244+
# git stash clear /* removes all stash */
245+
# git stash drop stash@{0}
246+
247+
# Reset to remote state:
248+
# git fetch origin
249+
# git reset --hard origin/$DEFAULT_BRANCH
205250

206251
# echo "******** Cover your tracks:"
207252
# Remove from repository all locally deleted files:

0 commit comments

Comments
 (0)