-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGitBash.txt
executable file
·183 lines (133 loc) · 8.17 KB
/
GitBash.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
// ===========================================================================
/// <summary>
/// Git quick guide
/// PracticalGuide
/// created by Mehrdad Soleimanimajd on 26.01.2019
/// </summary>
/// <created>ʆϒʅ, 26.01.2019</created>
/// <changed>ʆϒʅ, 03.07.2023</changed>
// ===========================================================================
the following is a sum of hours research in internet and noted to be quick. If you aren't already know the git concepts, the following isn't for you.
references: https://git.github.io/git-reference
https://stackoverflow.com
https://git-scm.com/
https://docs.github.com
https://linuxize.com/
https://google.com.search
https://dev.classmethod.jp
https://support.beanstalkapp.com
https://toolsqa.com
https://superuser.com
https://docs.microsoft.com
https://softwareengneering.stackexchange.com
#Description# #Command#
general commands:
current path pwd
change path cd path (1Ex: /c:/users/ 2Ex(if spaces): "/c/program files/")
one directory up cd ..
log (topology) git log --topo-order (exit q, help h)
global exclusion git config core.excludesfile fullPathTo.gitignore
clone git clone git@github.com:repositoryPath.git
git clone git@ssh.dev.azure.com:v3/repositoryPath
fetch git fetch alias
push git push alias branch
git push --force alias branch
sub-modules git submodule add URL
git submodule update --init
git submodule update --init --recursive
terminate exit
an ever running show more :)
~use the letter q
paste Shift + Ins
help git help
git help command
SSH keys:
check ls -al ~/.ssh
generate ssh-keygen -t ed25519 -C "email address"
ssh-keygen -t rsa -b 4096 -C "email address"
~on macOS or Linux it may be needed to insert the hardware security key
copy pbcopy < ~/.ssh/ ... .pub
ssh-agent (launched) eval "(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
~auto launch: give it a research! :)
passphrase ssh-keygen -p -f ~/.ssh/id_ed25519
test ssh -T git@github.com
ssh -T git@ssh.dev.azure.com
signing keys commit/tag signature:
SSH (most simple)
GPG (private development)
S/MIME (organization)
check
//TODO
clean operations:
repository git gc --auto
all repository for line in $(find -name '.git'); do (cd $line && git gc --auto); done
remote:
add git remote add alias URL
set git remote set-url alias URL
rename git remote rename old-alias new-alias
show git remote -v
configuration:
author git config --global user.name "name"
git config --global user.email "email"
ssh signing git config --global gpg.format ssh
git config --global commit.gpgsign true
git config --global user.signingkey pathToKey.pub
gpg signing git config --global commit.gpgsign true
git config --global user.signingkey [shortId]
check git config --list
repository:
check git log --format=oneline/short/fuller/raw/...
git show -s --format=...
new git init .
git remote add origin git@...
git touch README
git add README
git commit -m 'Initialization'
git push [--force] origin master
snapshotting:
status git status -s
summary git diff -stat
differences git diff
git diff --cashed (staged)
git diff head (staged or not)
stage git add .
git restore --staged .
commit git commit -m 'comment'
git commit -am 'comment' (auto staging)
commit modification git commit [--amend] -m 'new-comment' -S
~new changes can be staged beforehand
~modified commit must be force pushed
rewrite history git rebase -i head~5
~show latest 5 commit
reset:
un-stage a file git reset head -- file
undo last commit git reset --soft HEAD^
undo and erase changes git reset --hard head
staged modification:
remove git rm file
git rm file --cached (just from staged)
correct wrong rename git mv
~a removed old file ended wrongly as a rename
postpone:
push on stack git stash
view stack git stash list
pop from stack git stash apply
git stash apply stashId
remove from stack git stash drop stashId
----------------------------------------------------------------------
~on the road to getting acquainted to the git entity first got acquainted to these beauties! :)
----------------------------------------------------------------------
execute commands:
find . -maxdepth 1 -type d \( ! -name . \) -exec sh -c 'cd -p "$0" && git remote rename origin origin-gh && pwd' {} \;
ls -d */ | xargs -I {} bash -c "cd {} && git remote rename origin origin-gh | pwd"
for dir in ./*; do (cd "$dir" && git remote rename origin origin-gh && pwd); done
----------------------------------------------------------------------
finding big files:
find . -type f \( ! -regex ".*/\..*" \) -print | xargs ls -l | sort -k5,5rn | head
----------------------------------------------------------------------
deleting big unnecessary files in commits: (+afterNeed git push --force)
git filter-branch -f --index-filter \
'git rm --cached --ignore-unmatch fullPathToBigFile.ex' \
--tag-name-filter cat -- --all
----------------------------------------------------------------------