forked from srinivas1987devops/myweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
arun-git.txt
361 lines (154 loc) · 8.92 KB
/
arun-git.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
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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
Git ( vcs / SCM ) version control system / source code management.
Below are the functions of a VCS −
1. Allows developers to work simultaneously.
2. Does not allow overwriting each other’s changes.
3. Maintains a history of every version.
The Following are the types of VCS −
1. Centralized version control system (CVCS). ===>> SVN
2. Distributed/Decentralized version control system (DVCS). ===> Git.
we will concentrate only on distributed version control system and especially on Git. Git falls under distributed version control system.
GIT ===>> alternative older VCS ==>> SVN.
Centralized version control system (CVCS) uses a central server to store all files and enables team collaboration.
But the major drawback of CVCS is its single point of failure, i.e., failure of the central server.
Unfortunately, if the central server goes down for an hour, then during that hour, no one can collaborate at all.
And even in a worst case, if the disk of the central server gets corrupted and proper backup has not been taken,
then you will lose the entire history of the project. Here, distributed version control system (DVCS) comes into picture.
==========================================================================================================================================
DVCS clients not only check out the latest snapshot of the directory but they also fully mirror the repository.
If the server goes down, then the repository from any client can be copied back to the server to restore it. Every checkout is a full backup of the repository.
Git does not rely on the central server and that is why you can perform many operations when you are offline.
You can commit changes, create branches, view logs, and perform other operations when you are offline.
You require network connection only to publish your changes and take the latest changes
==================================================================================================================================================
Git terminalogy :
Git is a client server architecture.
client ===>> gitbash and server.===>> github
repository : group of project files to store one single area and each project has one repository.==>>> github has ==>> n . no.of repositories..
cloning : remote reposiory ( myweb ) to getting the local ==>>> cloning ==>>> git clone url ( each project has one url) ===>> locally
fork : projects are copied from one github account to another github account.
local repository : getting the remote repository ( myweb) to our local laptop.
remote repository : github ==>> our created repository ( myweb )
push : sending local repository changes to remote repository
pull : sending the remote repository changes to the local repository
Note : git follows ===>> 2 types of protocalls ==>>> https and ssh.
=====================================================================================================
Git workflow :
1. we need to clone remote repository to local..
git clone url
git clone https://github.com/srinivas1987devops/myweb.git
ls
2. go to the inside local repository.
cd myweb
3. files ==>>> create / modify ===>> working area.
touch rk123
git status ==>> red color ==>> working area.
4. git add . / filename / *
git status
file ==>> green color ===>> INdexing / staging area.
5. we are getting the files to local repository ==>> commit
git commit -m 'rk2020' ==>> local repository.
git log
40 digits commitiD ==>>> head ==>> head always points to latest commit.
6. push to remote repository..
git push origin master
push ==>>> sending local changes to remote repository..
origin ==>> alias name ==>>> github url
master ==>> default branch.
=========================================================================
git config --global user.name “ramakrishnaj2020”
git config --global user.email “[email protected]”
git push origin master ==>> githubaccountname and github passsowrd ==>>> remote.
==================================================================================
How to undo changes in working area ??
file ==>> modify ==>> working area
git checkout filename.
How to undo the changes in index/ staging area
file ==>> modify ==>> working area
git add . / filename / * ==>> index / staging area
git reset filename
How to undo the changes the in local repository.
file ==>> modify ==>> working area
git add . / filename / * ==>> index / staging area.
git commit -m 'b123'
git log
git reset commitid
========================================================================
**** ===>>>> Branching strategies:<<===============
1. master branch ===>>> default branch
2. developement branch ( dev ) ==>>> every team has their own branch ==>> which is created from master branch.
3. feture branch ==>> every developer has their own branch ==>> which is created from dev branch.
4. hotfix / bugfix branch ==>> errors / bugs ===> which is created from master branch.===>> errors free ==>>> hotfix / bugfix branch will delete.
5. Release branch.===>> every release has one branch with version ==>> which is created from master branch. ==>> once release push to remote ==>> Release branch will delete.
Branch : To develope the code of our project.
How to create branch in locally ??
git branch branchname
How to push local branch remote ???
git push origin branchname
How to delete local branch
git branch -d branchname
How to delete remote branch
git push origin -d branchname
How to go to inside a branch
git checkout branchname
===================================
***** merging strayegies in locally ****
1. fast-forward
2. twoway or recursive merge
3. git rebase ( dangerous)
===============================================================================
git cherry-pick :
It picks a commit from one branch and applys it to another branch with out doing merge.
git cherry-pick commitid.
==================================================================================
How to merge the remote side changes ===>>> pull request.
pull request ==>> remote side branches ==>>> github ===>> in between the branches ==>> merging is nothing but pull request.
pull request ==>> TL / collegues ===>> approval ==>> merge pull request ==>> conform merge.
pull request ==>>> source and destination
source ( right side ) and destination ( left side).
==================================================================================
tags : tags are used to release the application or code version or feture version.
list of tags to see ==>> git tag
how to create a tag locally ??
git tag tagname
git tag v1.0
how to push local tag to remote
git push origin taganme
git push origin v1.0
tags are create on the perticular commit.
git tag tagname commitid
tags are created from the master branch only..
how to delete a tag locally
git tag -d tagname
how to delete remote tags
git push origin -d tagname.
=================================================================================
git stash :
bhargavi ==>> developer ==>> mno file ==>>> working area , index area ===>> before going to commit ==>> P1 ( priority one task ==>>> 2 hours close) .
bharagavi ==>>> developer ==>>> mno file ==>>> tempararily save ==>> git statsh.
after completion of the p1 task ==>> tempararily save ==>> unstash ==>> after that commit.
git stash save ==>>> tempararily save
git stash list ==>> stash {0}
git stash apply stashid stash {5} or git stash pop stashid stash {5} ==>> unstash
git commit -m 'c1'
git push origin master.
===============================================================================================
merge conflicts ( locally )
ramakrishna ==>> developer
siva ===>> developer
both develoeprs are working on the same file ===>>> pqrs ===>> same line ==>> 151
siva ==>> developer ==>> dev branch ==>>> merge ==>>> unable to merge.
git merge tool
pqrs ==>> will open ==>> 151 << >> ==>> brackets ==>>> remove the brackets
pull request conflicts ( remote side)
sekhar ==>> developer
sundar ===>> developer
both develoeprs are working on the same file ===>>> mno ===>> same line ==>> 351
sundar ==>> developer ==>> dev branch ==>>> pullrequest ==>>> unable to pullrequest. ===>> resolve conflicats.
mergeconflicts ===>>> click this ==>>>> mno ==>>> open
mno ==>> will open ==>> 351 << >> ==>> brackets ==>>> remove the brackets.
===============================================================================================
1. release branch
2. pullrequest.
3. tags
4. github ==>> backup.
======================================================================================================