-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstruction.ps1
245 lines (124 loc) · 8.94 KB
/
instruction.ps1
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
docker build -t cicddemoapp . ### build the image from the dockerfile in the current directory, the image name is cicddemoapp
docker tag cicddemoapp ezio22/cicddemoapp:latest ### tag the image with the repository name, in this case it is ezio22/cicddemoapp, and the tag is latest
docker login ### login to docker hub, you need to have an account on docker hub
docker pull ezio22/cicddemoapp:latest ### after we build the image we pushed it to docker hub, or coudld be any container registry.
docker run -p 8080:8080 ezio22/cicddemoapp ### we run the image on port 8080 locally to test it.
### pulling from GHCR and run it
## I built an image using github workflow and pushed it to GHCR, the image is available at github packages
docker pull ghcr.io/eziodevio/ghcr-democicdapp:430e8b34dcb45d41239eab8d1ee1d0b14e3cc3fd430e8b34dcb45d41239eab8d1ee1d0b14e3cc3fd ### pull the image from GHCR
docker run -p 8080:8080 ghcr.io/eziodevio/ghcr-democicdapp:430e8b34dcb45d41239eab8d1ee1d0b14e3cc3fd ### run the image on port 8080 locally to test it.
#######################################################################################################################
save a file using Vim
press i to enter insert mode
type your text
press esc to exit insert mode
type :wq to save and exit
press enter
to exit without saving press esc and type :q! and press enter
save a file using nano
press ctrl+o to save
press enter
press ctrl+x to exit
save a file using cat #
cat > filename
type your text
press ctrl+d to save and exit
save a file using echo #
echo "your text" > filename
################################################### GIT OPERATION #######################################################
git status ### check the status of the git repository
git init ### initialize a new git repository
git add filename1 filename2 ### add the files to the staging area
git add . ### add all the files to the staging area
git commit -m "A descriptive message explaining your changes" ### commit the changes to the local repository
git remote add <remote-name> <remote-url> ### add a remote repository
git push origin main ### push the changes to the remote repository
git push origin your-branch-name ### push the changes to the remote repository
git pull origin main ### pull the changes from the remote repository
git pull origin your-branch-name ### pull the changes from the remote repository
git checkout -b your-branch-name ### create a new branch and switch to it
git checkout your-branch-name ### switch to an existing branch
git branch -d your-branch-name ### delete a branch
git branch ### list all the branches
git log ### show the commit history
git log --oneline ### show the commit history in one line
git log --oneline --graph ### show the commit history in one line with a graph
git log --oneline --graph --all ### show the commit history in one line with a graph including all branches
git reset --hard commit-hash ### reset the repository to a specific commit
git reset --hard origin/main ### reset the repository to the remote main branch
git reset --hard origin/your-branch-name ### reset the repository to the remote branch
git reset --hard HEAD ### reset the repository to the last commit
git reset --hard HEAD~1 ### reset the repository to the commit before the last commit
git reset --hard HEAD~n ### reset the repository to the commit before the last n commits
git reset --hard HEAD^ ### reset the repository to the commit before the last commit
git reset --hard HEAD^n ### reset the repository to the commit before the last n commits
git reset --hard HEAD@{1} ### reset the repository to the commit before the last commit
git clone <repository-url> ### clone a remote repository to your local machine
git clone <repository-url> <folder-name> ### clone a remote repository to a specific folder on your local machine
git branch -r ### list all the remote branches
git branch -a ### list all the local and remote branches
git checkout -b <new-branch-name> origin/<remote-branch-name> ### create a new branch and switch to it, based on a remote branch
git fetch ### fetch the latest changes from the remote repository
git merge <branch-name> ### merge changes from a different branch into the current branch
git diff ### show the differences between the working directory and the last commit
git diff --staged ### show the differences between the staging area and the last commit
git stash ### temporarily save changes that are not ready to be committed
git stash apply ### apply the most recent stash
git stash list ### list all the stashes
git stash drop ### remove the most recent stash
git remote -v ### list all the remote repositories
git remote remove <remote-name> ### remove a remote repository
git remote rename <old-name> <new-name> ### rename a remote repository
git remote set-url <remote-name> <new-url> ### change the URL of a remote repository
git tag ### list all the tags
git tag <tag-name> ### create a new tag
git tag -a <tag-name> -m "Tag message" ### create an annotated tag with a message
git push origin --tags ### push all the tags to the remote repository
git push origin :<tag-name> ### delete a tag from the remote repository
git show <commit-hash> ### show the details of a specific commit
git blame <file-name> ### show who made the last changes to each line of a file
git cherry-pick <commit-hash> ### apply the changes from a specific commit to the current branch
git rebase <branch-name> ### move the current branch to the tip of another branch
git reset <file-name> ### unstage a file
git reset --hard ### discard all the changes and reset to the last commit
git clean -f ### remove untracked files from the working directory
git config --global user.name "Your Name" ### set your name for commit messages
git config --global user.email "your-email@example.com" ### set your email for commit messages
###########################################################################################################################
################################################### DOCKER OPERATION #######################################################
docker ps ### list all the running containers
docker ps -a ### list all the containers
docker images ### list all the images
docker build -t image-name . ### build an image from the dockerfile in the current directory
docker run -p host-port:container-port image-name ### run a container from an image
docker run -p 8080:8080 image-name ### run a container from an image on port 8080
docker run -d image-name ### run a container in detached mode
docker exec -it container-id /bin/bash ### execute a command in a running container
docker stop container-id ### stop a running container
docker rm container-id ### remove a container
docker rmi image-id ### remove an image
docker pull image-name ### pull an image from a registry
docker push image-name ### push an image to a registry
docker login ### login to a container registry
docker tag image-name registry/image-name ### tag an image with a registry
docker-compose up ### start the services defined in a docker-compose file
docker-compose down ### stop the services defined in a docker-compose file
docker-compose ps ### list the services defined in a docker-compose file
docker-compose logs ### show the logs of the services defined in a docker-compose file
docker-compose exec service-name command ### execute a command in a service defined in a docker-compose file
docker-compose build ### build the services defined in a docker-compose file
docker-compose pull ### pull the images for the services defined in a docker-compose file
docker-compose push ### push the images for the services defined in a docker-compose file
docker-compose stop ### stop the services defined in a docker-compose file
docker-compose rm ### remove the services defined in a docker-compose file
docker-compose restart ### restart the services defined in a docker-compose file
docker-compose up -d ### start the services defined in a docker-compose file in detached mode
docker-compose down -v ### stop the services defined in a docker-compose file and remove the volumes
docker-compose up -d --build ### start the services defined in a docker-compose file in detached mode and rebuild the images
docker-compose up -d service-name ### start a specific service defined in a docker-compose file in detached mode
docker-compose down service-name ### stop a specific service defined in a docker-compose file
docker-compose logs service-name ### show the logs of a specific service defined in a docker-compose file
docker-compose exec service-name command ### execute a command in a specific service defined in a docker-compose file
docker-compose build service-name ### build a specific service defined in a docker-compose file
docker-compose pull service-name ### pull the image for a specific service defined in a docker-compose file
docker-compose push service-name ### push the image for a specific service defined in a docker-compose file