-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgit.txt
230 lines (189 loc) · 11.1 KB
/
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
=============================================VERSION CONTROL INTRODUCTION START===============================================
!!Version Control System(VCS) is a kind of database which lets you save a snapshot of the complete project at any point of time
!!Every change made to the project files is tracked, along with
-> Who made the change
-> Why the change was made(refernces to problems fixed or features added in the change)
!!later when it is required to take a look at an older snapshot/version, VCS shows how exactly it differed from the previous one
!!It help teams manage and track changes in code over time
!!Why version control system is needed?
1.COLLABORATION: if the developers works on a same project from different regions, it will be hard for them to collaborate without the version control system
2.STRONG VERSIONS: managing multiple versions of a project in your disk can be challenging as it requires storing and organizing a potentially large amount of data
3.RESTORING PREVIOUS VERSIONS: vcs offer the ability to roll back to a previous version if needed. If a mistake or issue is introduced, developers can revert to a known working state of the project
4.BACKUP: in casy of system or the disk of the user breaks down and there is no backup all the files will be lost hence vcs should be used
!!Types of VCS are:
1.Local Version Control System(file_1.txt->file_2.txt->file_3.txt)
2.Centralized Version Control System
3.Distributed Version Control System(Latest)
!!What is Git?
-> Git is a distributed vcs widely used in software development
-> It allows multiple developers to work collaboratively on a project
-> Can efficiently manage and track changes to the source code
!!How Git works?
-> Git stores its data in a series of snapshots of a miniature filesystem. Every time you commit change or save your project state, Git takes a snapshot of all your files at that moment and stores a refernces to that snapshot
-> A git project resides in three sections:
1.THE WORKING DIRECTORY: The single checkout of one version of the project
2.THE STAGING AREA: An index that stores information about what the next commit will contain
3.THE GIT REPOSITORY: The place where Git stores the metadata and object database for a project
8.08-10.37 - PROGRAMMING HERO
-> COMMIT -> STAGE -> REPOSITORY
-> GIT LAB, BIT BUCKET
=============================================VERSION CONTROL INTRODUCTION END===============================================
=============================================GIT CONFIGURATION START===============================================
!!we need to connect our git with our github account, we do it using git config
//set user name : git config --global user.name "your_name"
//set user email: git config --global user.email "your_email"
//check config : git config --list or git config -l
//to update the data, just reassign the data
!!for the first time after git configuration, when you want to push some document, you need to login/authenticate your github account
=============================================GIT CONFIGURATION END===============================================
=============================================INITIALIZING EMPTY REPOSITORY START===============================================
!!CREATING DOT GIT FOLDER
!!git init -> creating/initializing git repository(current path er vitor .git folder create hoi),here files are untrackable
!!git status -> displays the state of the working directory and staging area
=============================================INITIALIZING EMPTY REPOSITORY END===============================================
=============================================BASIC COMMAND START===============================================
!!You must run this command one by one, serially when you are creating completely new repository
!!CREATING NEW REPOSITORY
-> echo "write anything you want" >> file_name
-> git init
-> git add file_name
-> git commit -m "commit_message"
-> git branch -M branch_name
-> git remote add origin https://github.com/user_name/repository_name.git
-> git push -u origin branch_name
!!echo => create a new file and write something in it
!!init => first command to initialized empty git repository
!!add => add the file into staging state(from now it track changes)
!!commit => description of whcih changes did you make
!!branch => set the branch(you can create any number of branch, default vs code branch is master, github branch is main)
!!remote => connect local repository with remote repository
!!push => send the document to remote repository
!!HANDLING WORKING REPOSITORY
-> git add file_name
-> git commit -m "commit_message"
-> git push
!!whenever we made any changes in our working/local repository its recommened push it to remote repository
!!to push it we need add our changes to staging state
!!commit description of chnages
!!send it to remote repository
=============================================BASIC COMMAND END===============================================
=============================================STAGING & UNSTAGING START===============================================
!!STAGING
!!git add file_name -> take the file into staging state(here files are trackable)
!!git add -A -> stage all changed file in directory and subdirectories
!!git add . -> stage all changed file in directory but not subdirectories
!!git add *.extension -> stage all changed file in directory with specific extension
!!git add **/*.extension -> stage all changed file in directory and subdirectories with specific extension
!!after moving staging state, things are trackable, if we made any changes those are trackable
!!after making any changes, we have move the changes into staging state
!!git diff -> return the changes
!!git restore file_name -> remove the changes
!!UNSTAGING
!!git rm --cached file_name
=============================================STAGING & UNSTAGING END===============================================
=============================================COMMIT & UNCOMMIT START===============================================
!!COMMIT
!!git commit -m 'message here' -> moving staging to local repository(message should be clear and understandable)
!!git log -> return the history of git commit(that means you can commit git multiple time)
!!git commit -am 'message here'-> staging and commiting together
!!after commiting we are ready to move the local repository to the remote repository
!!UNCOMMIT
=============================================COMMIT & UNCOMMIT END===============================================
=============================================DOT GITIGNORE FILE START===============================================
!!.gitignore force to be untracked
!!which file that we do not want to share describe inside .gitignore
!!place the .gitignore file in your root directory
//ignore.txt -> ignore the ignore.txt file
//*.txt -> ignore all file which have .txt extension
//temp/ -> ignore the temp folder
//!main.txt -> ignore all file except main.txt
//ignore?.txt -> ignore all file which are similar to ignore1.txt,ignore2.txt,ignoreA.txt(it will match with one character after ignore)
//ignore????.txt -> ignore all file whcih is start with ignore with following 5 character
//ignore*.txt -> ignore all file which is start with ignore
!!git status displays working directory and staging area(tracked and untracked ) files
!!we can check is gitignore is working or not through git status
!!if it's working, then few file will be untracked
!!when we create a new repository, there have a option to add a .gitignore file
!!here we can select .gitignore template according to our application like node, android etc
=============================================DOT GITIGNORE FILE END===============================================
=============================================GITHUB HOSTING START===============================================
!!in your repository visit setting -> pages -> branch -> "select which branch do you want to host" -> save
!!this will host your repository at github.io
!!live view link: github_username.github.io/repository_name
!!github is CASE SENSITIVE, that's why we have to use exact file name
=============================================GITHUB HOSTING END===============================================
=============================================GIT ADVANCE COMMAND START===============================================
!!git remote -v => return the remote repository link
=============================================GIT ADVANCE COMMAND END===============================================
=============================================MARKDOWN START===============================================
!!Markdown is a lightweight markup language for creating formatted text using a plain-text editor
!! . md file extension (also written as . markdown) stands for "Markdown documentation"
!!mark down allow html syntax
!!create a file called README.md
!!comment : <!--Mark Down Comment-->
!!new line : use 2 spaces OR press enter or use <br/> tag
!!horizontal rule -> use three hyphen (---) or use <hr/> tag
//Before Horizontal
//---
//After Horizontal
!!heading : use space after a #,every # define a heading(h1->#,h2->##,h3->###),
!!paragraph : use <p> tag
!!italic : use <i> tag or use underscore before and after the text //_ITALIC TEXT_
!!strong/bold->use two underscore before and after teh text //__THIS IS BOLD TEXT__
!!strikethrough -> use double ~ or <del> tag //~~THIS IS STRIKE THROUGH~~
!!inline code block : use single back tick ( ` ) for single line,trible back tick for multiple line
//`This Is Code Block`
//```
//npm install
//npm start
//```
!!for language specific code use the language name
//```javascript
//console.log("Hello Universe");
//```
!!ORDER list -> you can use html tag or
//1. Item 1
//2. Item 2
// 1. Item 2.1
// 2. Item 2.2
!!unorder list use one hyphen( - )
//- Item 1
//- Item 2
// - Item 2.1
// - Item 2.2
!!task list -> use angle brackets [] with hyphen( - )
//- [X] Task 1
//- [X] Task 2
//- [X] Task 3
!!HYPERLINK
!!automatic link : just use the link
!!use back tick for disable link : `[email protected]`
!!link : [title](link)
//[Click me]([email protected])
!!MULTIPLE LINK
!!create something like variable -> [mail]: [email protected]
!!use the variable -> [CLICK ME][mail]
!!IMAGE
!!syntax : ![alt_text](link)
!!no space between those operator
!!you can also use the <img> tag
!!use emoji through copy paste
!!TABLE
!!use pipe symbol
!!always begin and end with pipe
//|Name|Email|
//|Masum Billah|[email protected]|
//|Sajib Kar|[email protected]|
=============================================MARKDOWN END===============================================
=============================================VISUAL STUDIO CODE START===============================================
!!OPEN VS CODE THROUGH CMD
!!visit your target path -> code . +enter
!!VS CODE TERMINAL
!!ctrl + j
!!KEY CHARACTER
!!U -> Untracked: nothing is added to staging state
!!A -> Added: added to staging state but no commit is done
!!M -> Modify: some changes are made
!!D -> Deleted
=============================================VISUAL STUDIO CODE END===============================================