-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGitHub Basics
More file actions
212 lines (103 loc) · 3.62 KB
/
Copy pathGitHub Basics
File metadata and controls
212 lines (103 loc) · 3.62 KB
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
Distributed Version Control System(Github)
IMPORTANT BASICS COMMANDS TO WORK WITH CODEBASE
1. Version of the Github (Ccheck the version)
git --version
2. Set config values
git config --global user.name "xyz"
git config --global user.email "[email protected]"
List the information regarding configurations
git config --list
3. Help regarding git commands
Example 1:
git help config
git config --help
Example 2:
git help add
git add --help
3. Initializing the repository from existing CODE
before going for initalization of a repository do the following
ls
ls -la // it will show hidden files
git init // Initializing local repository
check using ls -la
4.If we want to deactive as a repository (Untracking)
rm -rf .git
5. Before first commit
a) git status
If we want to ignore files
touch .gitignore
6. Working directory ----> Staging Area -----> .git directory(Repository)
7. Adding files to staging Area
git add .gitignore // only .gitignore file in stating area
git add -A // All files in staging area
8. Remove files from stating area
git reset .gitignore // remove only .gitignore from staging area
git reset // remove all files from staging area
git add -A // Add all files to staging area
9. Our first commit
git commit -m "label"
git status // how many commits are still pending
git log //log information time stamp
10. Cloning a remote repository
git clone <url>
git clone <url> .
11. Viewing information about remote repository
git remote -v // information of repository
git branch -a // all branches in repository either local or global
12. Push changes
git diff // changes in made CODE
git status
git add -A
git commit -m "Label"
THEN PUSH
git pull origin master // when working with multiple people working with on the same file and need to
update in the local repository
git push origin master // push changes made in code base of master in local repository to remote repository
13. COMMON WORKFLOW
A) CREATE A BRANCH FOR DESIRED FEATURE
git branch calcualtor //create a branch with name calcualtor
git checkout calcualtor // switch or toggle from master branch to calcualtor
git branch // know the status of current branch
git status // status of file if any modificaiton
git add -A
git commit -m "Label"
B) After commit push branch to remote
git branch -a
git push -u origin calcualtor
C) MERGE calcualtor branch to remote master
git checkout master //swithc from calcualtor to master
git pull origin master // if any modificaiton done by others on master
git branch --merged // status is Not yet merged calcualtor branch to master
git merge calcualtor // merge calcualtor branch to remote master
git push origin master // push record of local repository master to remote master repository
git branch --merge // status is merged calcualtor branch to master
D) DELETING A BRANCH
git branch --merged
git branch -d calcualtor
git branch -a
git push origin --delete calcualtor
git branch -a
14. FASTER Example
A) git branch sub
B) git checkout sub
C) git status
D) git add -Add
E) git commit -m "Label"
F) git push -u origin sub
G) git checkout master
H) git pull origin master
I) git merge sub
J) git push origin master
Tutorial 2:
15. git status
git diff
git checkout file.txt // rollback changes if any in file.txt
git commit -m "Subtract" // wrong commit message
git log // this is different
git commit --amend -m "Add" // Subtract commit is replced by Add
git log // this is different
Websites:
1) https://gist.github.com/arttuladhar/5887559
2) https://github.com/joshnh/Git-Commands
Tips for Beginners in Github
3) https://github.com/git-tips/tips