-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgit.development.from.starting.txt
204 lines (112 loc) · 6.45 KB
/
git.development.from.starting.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
<<<< Git Starting For Development <<<
------------------------------------------------------------------
keys: git cmds, git life cycle, staging area, checkout, pictorial graphp,
resource, development starting
------------------------------------------------------------------
------------------------------------------------------------------
------------------------------------------------------------------
------------------------------------------------------------------
1. To create empty branch, you have to go to terminal and execute:
git checkout --orphan branchname
git rm -rf .
add files:
---------
git add .
git commit -m "commit message"
git push -u origin branchname
-----------------------------------------------------------------------
Git Life Cycle:
--------------
https://intellipaat.com/blog/tutorial/devops-tutorial/git-tutorial/
git init git add
Working Dir *----------* Initialization *-----------------
*
|
----------------
| Staging Area |
----------------
|
*
GitHub *----------* Local Repositoty *------------------
git push git commit
-----------------------------------------------------------------------------------------
// Development Starting: Working from here
//Working on Git step by step cmds
//Git CMDS:
Example: 01
//1. Using git add (Go to staging area)
touch ajay.txt
git status
git add . //Adding files to staging area
git status
git restore --staged ajay.txt //Back to working dir
//2. Usign git commit (Go to local repository)
git add. ajay.txt //File adding to staging area
git status
git commit -m "file to local repository" //File go to local reposity
git status
git reset --soft HEAD^1 //ComeBackToStagingArea, If last commit is 1,
git status
git reset HEAD~ ajay.txt //Not used //If last commit is not first(or initial) Using: git reset HEAD~
//Not used //If last commit is first(or initial) Using: git update-ref -d HEAD
//3. Usign git push (Go to github)
----------------------------------------------------------------------------------------------------------
Checkout:
git checkout fileName //Last commit match to new (matching file)
git checkout -f //Recover all or one file matck (maching files)
-----------------------------------------------------------------------------------------
Showing Commits:
git log -p -1 //For one where is changes
git log -p -2 //
------------------------------------------------------------------------------------------
git diff -a //File compage working tree to staging area
git diff --staged //File compare with staging area to last commit
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
//Details with pictorial graphp
https://builtin.com/software-engineering-perspectives/git-reset-soft-head
_________________________________________________________________________________________________________
| | Local Git Repository | | | |
|_________________________________________________________________________________________________________|
^ | | | |
| | | | |
| | | | |
| | | | V git reset --soft
__________________________________________________________________________________________________________
| |git commit |git checkout Index(Staging Area) | |
|__________________________________________________________________________________________________________|
^ | | |
| | | |
| V | V git reset --mixed
___________________________________________________________________________________________________________
| | git add Working Directory | |
|___________________________________________________________________________________________________________|
|git reset --hard
V
What Flags Do We Use With the Git Reset Command?
git reset --soft HEAD~1
git reset --mixed HEAD~1
git reset --hard HEAD~1
-----------------------------------------------------------------------------------------
Some:
Git Restore:
The "restore" command helps to unstage or even discard uncommitted local changes.
git restore --staged index.html
git restore --staged *.css
git restore index.html
git restore --source 7173808e index.html
git restore --source master~2 index.html
------------------------------------------------------------------------------------------
Important Options:
https://www.git-tower.com/learn/git/commands/git-restore
<filename>
The name of a file (or multiple files) you want to restore
--staged:
Removes the file from the Staging Area, but leaves its actual modifications untouched.
modifications will remain untouched
--source <ref>
Restores a specific revision of the file.
--patch
Allows you to select individual chunks to restore.
-----------------------------------------------------------------------------------------