Repository navigation
Expand file tree
/
Copy pathgithub_notes
More file actions
232 lines (124 loc) · 7.3 KB
/
Copy pathgithub_notes
File metadata and controls
232 lines (124 loc) · 7.3 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
git status(inside Dir) = verify if the git is controlling this directory.
git init ( dir) = initialize git control in this directory.
create txt file gitignore = (writte the name of the (file or **directory or *.extension) inside the txt and git will no longer track it)
obs: git doesn´t track empty directories.
.git directory:
config:
if you create a new repo.
local: if your computer is public or used by 2 or more people.
git config user.name "GUIMS357"
git config user.email "guims357@gmail.com"
global: personal computer, you are the only user.
git config --global user.name "GUIMS357"
git config --global user.email "guims357@gmail.com"
Basic operations:
git add (file) = git star tracking the archive & if you modify the file usa add again to update afoter commit
git add . = add everything that was created or modified
git commit = it's like to take a picture of the project in this time space(situation)
add -m "to writte a messsage".
Hash ID = is the number of a snapshot, a "picture" of the project in a certain time
git log:
git log = show every commit maded and the respectives messages
if you see : you can replace for a / and add a word to search in the messages you added with -m
if you see : you can replace for a "q" to quit
head -> master is were we are now
git config core.pager cat = now git log will show every commit maded --global to change to all repos
git config core.page less = return to the previous mode
git flags:
git log -2 = last 2 comits ( chage the number to se more or less comits)
git log --oneline ( all the info in single line)
git log --before = "2020-05-25" = before or after and "AAAA-MM-DD" & since="x days/months/year ago"
git log --author = <name>
git help log
return to a previous comit:
git checkout Hash ID = return to a previous commit and undo all the changes
git chackout master = return to the head ( last commit)
more comands:
git mv <nactual name> <new name>
if youn chage a name of a file via S.O., you need to add a new status to them,. you need to git add <oldfilename>
git rm <name> = exclude a file
git diff --staged = compare this staged( green status, before add) file with the last commited file
use to check before commit
git diff <hash-id> diferrence between the file now and the commit with the especified hash
git diff <hash-id older>..<hash-id newer>
git commit --amend -m "new message" = change the message in the last commit or add new things to it
git restore --staged <file name> = remove from monitoring ( undo add command)
git checkout <file name> = return the file to the previous commit
git reset HEAD --hard = return all the files to the files in the previous commit
git reset HEAD^ --hard = return to the last HEAD and discard the last commit
branch and derivatives
is a branch in the main code that can be developed in other ways to obtain different resultor or, can be used to test some implementations keeping the main code safe
---------------> branch
-----------/----/----------------------> project ( each - is a comit) and this is the branch master
--------------> branch ( to add a function or modify something than can broke the project)
the comiit with " / " is the base of the new branch
branch:
git branch <name> = to create a new branch with the specified name
git branch = show every branch of the project ( * represents the branch currently used)
git checkout < branchname> = chenge to the selected branch
git branch -D <name> = delete branch
git branch -d <name> = delete only merged branchs
git merge < branch name> = i will merge into your actual branch the selected branch( name you specified)
git checkout -b <name> = create and acess the new branch it's like a branch+checkout
rebase:
it's like a merge
merge insert the branch were you are now
rebase insert in the BASE were you open the branch
git rebase <name>
clone & push:
git clone <adress of the original repo> <were the new repo will be ( use '.' if you want were the terminal was opened)> = clone repository that exists, after clone you have the original repository as a local repository and
you can att both using the other
git push = send the modifications(commits) to the original repo/root repo/ central repo
git push origin = send to the bare repo
fetch & pull:
fetch = download att from a remote repo but doesn't apply to our local repo (don't do a merge so, you can do a rebase instead)
you need to use rebase to add the files
pull = download att from a remote repo and apply to the repo (fetch+rebase)
ctrl+o to writte
ctrl+x to exit
bare repository:
root repository, were everyone puts his commits
git init --bare = create a bare repository
this will be the root/central/original repo, it's where the project started
tags:
it's like branches but you can´t commit anymore
you can create a branch of a tag
it's used to create stable versions of products even if it is incomplete
but can be deployed in production
you can create a release 1.0, 1.1, 1.2 ...
git tag = show tags
git tag <tag name> = create tag
git remote -v
git config credential.helper store
to save login and password
to send to a remote directory
git push -u <origin>( were you get it form) <branch name>
adding new collaborators:
at the github project page, go to settings, manage access and search the collaborator
the collaborator needs to accept the invitation
commit historic at github:
at github, open repo, click in commits and ou can see every commit, colaborator, data, hour, ID and what the person did.
checkouts again:
git checkout -- . = all the files return to their original status
git checkout -- <filename> = returnthe file to original status ( before M status)
it the archive is at pre commit status use
git checkout HEAD -- .
git checkout HEAD -- <filename>
revert and reset:
git revert <commit ID(usualy the one with the wrong section)> if you do a commit and did something wrong (added a code section),you can fix( erase the code section),and it will create a new commit without tht section but it will not erase any commit
it will mantain the commit with the wrong section
it's used to mantain a track of the commits
git reset HEAD~<number of commits you wanto to erase> remove the commit
conflicts, occour when two people modify THE SAME file:
in merges or rebases = when you try to push your repository to the github and it is older than the repo on git( someone had changed and maded a push before you)
you need to download the newer version
he will thell you that you have a conflict ( content and specify the file)
the git will show the conflict and itś your responsability to solve the conflicts manually and remove the comments.
Issues: it's like todo things,
planning what you will do next,bugs, things that you did wrokg and are not working
you can close in commit using Closes #<number of the issue>
Fork: you create a new repo with the code of other person in your personal github page and the repo will be full independent, it's like I have created a project from begginig
you are creating a new personal repo based on an existing repo.
pull request: when you fork a project and modify them, you can do a pull request and if the original owner accept to include your code to the original project
ideally you create a branch and test using = git fetch origin pull/<pull request ID>/head: <branch name (what are you doing, what is it for)>
git checkout