├── git_clone_with_ssh.md ├── .gitignore ├── LICENSE └── README.md /git_clone_with_ssh.md: -------------------------------------------------------------------------------- 1 | How to git clone with ssh? 2 | 1. Open terminal, run `ssh-keygen -t ed25519 -C "your_email@example.com"` 3 | 2. Keep pressing enter (if you don't want passphrase) 4 | 3. Open `~/.ssh/id_ed25519.pub` 5 | 4. Copy the public key 6 | 5. Go to https://github.com/settings/keys 7 | 6. Click 'New SSH Key' 8 | 7. Title: Put name of device 9 | 8. Paste public key 10 | 9. Click 'Add SSH key' 11 | 10. Now you can just git clone or git push without typing the password again. 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Version control and Git - Hands-on 2 | 3 | ### Overall topics: 4 | 5 | - Git add 6 | - Git commit 7 | - Git push 8 | - Git pull 9 | - Git log 10 | - Git restore --staged 11 | - Git reset --soft 12 | - Git status 13 | - Git branch 14 | - Git checkout 15 | - Git merge 16 | - Git diff 17 | - Git remote 18 | - Git clone 19 | - Git fetch 20 | - Git submodule 21 | - Fork 22 | - Pull request 23 | - GitHub issues 24 | - .gitignore file 25 | 26 | ### Requirements and commands to install: 27 | 28 | 1. Create an account on [GitHub](github.com) 29 | - Use your personal email address and then link your university email address to your GitHub account 30 | 31 | 2. Create a new repository on GitHub 32 | 33 | 3. Install Git on your computer (if you don't have it already) using the following command: 34 | 35 | ```bash 36 | sudo apt install git 37 | ``` 38 | 39 | 4. [Optional] If you want to see the active branch name in your terminal, something like this: 40 | 41 | ```bash 42 | user@computer:~/path/to/your/project (branch-name)$ 43 | ``` 44 | 45 | Then, you can add the following lines to your bashrc file: 46 | 47 | Note: What is a bashrc file? It is a file that is executed every time you open a terminal. It is used to set up your terminal environment. 48 | 49 | - Open the bashrc file using the following command: 50 | 51 | ```bash 52 | gedit ~/.bashrc 53 | ``` 54 | 55 | - Add the following lines at the end of the file: 56 | 57 | 58 | ```bash 59 | # Show git branch name 60 | force_color_prompt=yes 61 | color_prompt=yes 62 | parse_git_branch() { 63 | git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' 64 | } 65 | if [ "$color_prompt" = yes ]; then 66 | PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ ' 67 | else 68 | PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ ' 69 | fi 70 | unset color_prompt force_color_prompt 71 | ``` 72 | 73 | 5. If you want to clone and push without using a password, follow these steps to enable the SSH key [HERE](https://github.com/kvnptl/practice_git/blob/main/git_clone_with_ssh.md) 74 | 75 | 5. From today onwards, use git to manage all your projects 76 | 77 | 6. Also, put all the foundation course files on your GitHub account 78 | 79 | 7. Get the Git cheatsheet from GitHub Education | [Git cheat sheet](https://education.github.com/git-cheat-sheet-education.pdf) 80 | 81 | ### Basic git workflow: 82 | 83 | 1. Configure Git on your computer using the following commands: 84 | 85 | - First, check if you have Git configured on your computer using the following command: 86 | 87 | ```bash 88 | git config --list 89 | ``` 90 | 91 | - If you don't have Git configured on your computer, then configure it using the following commands: 92 | 93 | 94 | ```bash 95 | git config --global user.name "Your Name" 96 | git config --global user.email "dontcopythis@whatever.com" 97 | ``` 98 | 99 | 2. Create a new directory on your computer and clone the repository you created on GitHub using the following command: 100 | 101 | ```bash 102 | git clone 103 | cd 104 | ls -a 105 | ``` 106 | 107 | 3. Create a readme file and add some text to it using the following command: 108 | 109 | ```bash 110 | touch README.md # md stands for markdown 111 | gedit README.md # or use your favorite text editor (e.g. vim, nano, etc.) 112 | ``` 113 | 114 | 4. Check the status of the repository using the following command: 115 | 116 | ```bash 117 | git status 118 | ``` 119 | 120 | - You should see that the readme file is untracked and that you have one untracked file 121 | 122 | 5. Add the readme file to the staging area using the following command: 123 | 124 | ```bash 125 | git add README.md 126 | ``` 127 | 128 | 6. Check the status of the repository using the following command: 129 | 130 | ```bash 131 | git status 132 | ``` 133 | 134 | - You should see that the readme file is staged and that you have one staged file (in green) 135 | 136 | 7. Commit the readme file to the repository using the following command: 137 | 138 | ```bash 139 | git commit -m "Add README.md" # -m stands for a message 140 | ``` 141 | 142 | 8. Check the status of the repository using the following command: 143 | 144 | ```bash 145 | git status 146 | ``` 147 | 148 | - You should see that the readme file is committed and that you have one committed file (in green) 149 | 150 | 9. Check the log of the repository using the following command: 151 | 152 | ```bash 153 | git log 154 | ``` 155 | 156 | - Git log shows the history of the repository 157 | - It shows the commit hash, the author, the date, and the commit message 158 | - It also shows the HEAD (the current commit) and the branch name (main) 159 | - You can exit the log by pressing `q` 160 | 161 | ```bash 162 | git log --oneline 163 | ``` 164 | 165 | - Git log oneline shows the history of the repository in a compact way 166 | - It shows the commit hash and the commit message 167 | - You can exit the log by pressing `q` 168 | 169 | 10. Push the changes to the remote repository using the following command: 170 | 171 | ```bash 172 | git push 173 | ``` 174 | 175 | - How to get the remote name and branch name on the terminal: 176 | 177 | ```bash 178 | git remote -v # -v stands for verbose 179 | git branch 180 | ``` 181 | 182 | 11. Check the status of the repository using the following command: 183 | 184 | ```bash 185 | git status 186 | ``` 187 | 188 | - You should see that the readme file is up to date and that you have nothing to commit 189 | 190 | 12. Make some changes to the readme file and save them 191 | 192 | 13. Check the status of the repository using the following command: 193 | 194 | ```bash 195 | git status 196 | ``` 197 | 198 | - You should see that the readme file is modified and that you have one modified file 199 | 200 | 14. Add the readme file to the staging area using the following command: 201 | 202 | ```bash 203 | git add README.md 204 | ``` 205 | 206 | 15. Check the status of the repository using the following command: 207 | 208 | ```bash 209 | git status 210 | ``` 211 | 212 | - You should see that the readme file is staged and that you have one staged file (in green) 213 | 214 | 16. Commit the readme file to the repository using the following command: 215 | 216 | ```bash 217 | git commit -m "Update README.md" 218 | ``` 219 | 220 | 17. Check the status of the repository using the following command: 221 | 222 | ```bash 223 | git status 224 | ``` 225 | 226 | - You should see that the readme file is committed and that you have one committed file (in green) 227 | 228 | 18. Check the log of the repository using the following command: 229 | 230 | ```bash 231 | git log 232 | ``` 233 | 234 | - You should see the history of the repository 235 | 236 | 19. Push the changes to the remote repository using the following command: 237 | 238 | ```bash 239 | git push 240 | ``` 241 | 242 | 20. Check the status of the repository using the following command: 243 | 244 | ```bash 245 | git status 246 | ``` 247 | 248 | - You should see that the readme file is up to date and that you have nothing to commit 249 | 250 | Note: a few numbers are missing, but you can still follow the tutorial 251 | 252 | ### Now that you know the basic commands, we'll go through some more advanced commands 253 | 254 | 23. Create a new file, put some text, and stage it 255 | 256 | 24. Add some changes to the readme file and save them 257 | 258 | 25. Check the status of the repository using the following command: 259 | 260 | ```bash 261 | git status 262 | ``` 263 | 264 | 26. Add the readme file to the staging area using the following command: 265 | 266 | ```bash 267 | git add README.md 268 | ``` 269 | 270 | 27. Check the status of the repository using the following command: 271 | 272 | ```bash 273 | git status 274 | ``` 275 | 276 | 28. Now that you have some changes in the staging area, and for some reason you want to undo the changes, you can use the following command: 277 | 278 | ```bash 279 | git restore --staged README.md 280 | ``` 281 | 282 | - This command will undo the changes in the staging area 283 | - You can see the same command in the git status output 284 | 285 | 29. Check the status of the repository using the following command: 286 | 287 | ```bash 288 | git status 289 | ``` 290 | 291 | 30. Now, for example, if you committed some changes and you want to undo the commit, you can use the following command: 292 | 293 | ```bash 294 | git reset --soft HEAD~1 # --soft means that the changes will be in the staging area 295 | ``` 296 | 297 | or 298 | 299 | ```bash 300 | git reset --soft # commit id of the commit to go to 301 | ``` 302 | 303 | - The difference between the two commands is that the first one will undo the last commit, and the second one will undo the commit with the specified commit hash 304 | - `reset --soft` means that the changes will be in the staging area 305 | 306 | - There are different types of reset, like `reset --mixed` and `reset --hard`, that you can read about [here](https://git-scm.com/docs/git-reset) 307 | 308 | 31. Check the status of the repository using the following command: 309 | 310 | ```bash 311 | git status 312 | ``` 313 | 314 | - You should see that the changes are in the staging area and that you have one staged file (in green) 315 | 316 | 32. You can also change the commit message of the last commit using the following command: 317 | 318 | ```bash 319 | git commit --amend -m "new Update README.md" 320 | ``` 321 | 322 | 33. Check the log of the repository using the following command: 323 | 324 | ```bash 325 | git log 326 | ``` 327 | 328 | - You should see the history of the repository 329 | 330 | 34. Push the changes to the remote repository using the following command (try without -f, and then with -f): 331 | 332 | ```bash 333 | git push -f 334 | ``` 335 | 336 | 35. Check the status of the repository using the following command: 337 | 338 | ```bash 339 | git status 340 | ``` 341 | 342 | - You should see that the readme file is up to date and that you have nothing to commit 343 | 344 | 36. Now we'll see how to compare the changes between two commits 345 | 346 | ```bash 347 | git diff 348 | ``` 349 | 350 | - You can only compare two commits at a time 351 | - You can also compare the changes between the working directory and the staging area of a specific file using the following command: 352 | 353 | ```bash 354 | git diff --staged # remove --staged, if it is just modified and not staged 355 | ``` 356 | 357 | # Git Branches 358 | ### Now we'll see how to create a new branch 359 | 360 | - Branches are used to develop features isolated from each other 361 | - The main branch is the default branch when you create a repository 362 | - Generally, on real projects, you should never work on the main branch, and you should always create a new branch for each feature you want to develop 363 | - Main branch is used to deploy the application to production 364 | 365 | 37. List down all the branches using the following command: 366 | 367 | ```bash 368 | git branch 369 | ``` 370 | 371 | - You should see that you are on the main branch 372 | 373 | 38. Create a new branch using the following command: 374 | 375 | ```bash 376 | git branch 377 | ``` 378 | 379 | 39. List down all the branches using the following command: 380 | 381 | ```bash 382 | git branch 383 | ``` 384 | 385 | - You should see that you are on the main branch and that you have a new branch 386 | 387 | 40. Switch to the new branch using the following command: 388 | 389 | ```bash 390 | git checkout 391 | ``` 392 | 393 | or 394 | 395 | you can merge two commands into one using the following command: 396 | 397 | ```bash 398 | git checkout -b 399 | ``` 400 | 401 | - This command will create a new branch and switch to it at the same time 402 | 403 | 41. List down all the branches using the following command: 404 | 405 | ```bash 406 | git branch 407 | ``` 408 | 409 | - You should see that you are on the new branch 410 | 411 | 42. Add some changes to the readme file and save them 412 | 413 | 43. Check the status of the repository using the following command: 414 | 415 | ```bash 416 | git status 417 | ``` 418 | 419 | 44. Add the readme file to the staging area and commit the changes using the following commands: 420 | 421 | ```bash 422 | git add README.md 423 | git commit -m "put some changes in the readme file" 424 | ``` 425 | 426 | 45. Check the status of the repository using the following command: 427 | 428 | ```bash 429 | git status 430 | ``` 431 | 432 | 46. Switch to the main branch using the following command: 433 | 434 | ```bash 435 | git checkout main 436 | ``` 437 | 438 | 47. List down all the branches using the following command: 439 | 440 | ```bash 441 | git branch 442 | ``` 443 | 444 | - You should see that you are on the main branch 445 | 446 | 48. Check the readme file, and you will see that the changes are not there 447 | 448 | 49. Switch to the new branch using the following command: 449 | 450 | ```bash 451 | git checkout 452 | ``` 453 | 454 | 50. List down all the branches using the following command: 455 | 456 | ```bash 457 | git branch 458 | ``` 459 | 460 | - You should see that you are on the new branch 461 | 462 | 51. Check the readme file, and you will see that the changes are there 463 | 464 | 52. Push the changes to the remote repository using the following command: 465 | 466 | ```bash 467 | git push 468 | ``` 469 | 470 | - This command will push the changes to the remote repository, but it will not merge the changes to the main branch 471 | - It will only create a new branch in the remote repository with the same name as the local branch 472 | 473 | #### Now we'll see how to merge the changes from the new branch to the main branch 474 | 475 | 53. Switch to the main branch using the following command: 476 | 477 | ```bash 478 | git checkout main 479 | ``` 480 | 481 | 54. List down all the branches using the following command: 482 | 483 | ```bash 484 | git branch 485 | ``` 486 | 487 | - You should see that you are on the main branch 488 | 489 | 55. Merge the changes from the new branch to the main branch using the following command: 490 | 491 | ```bash 492 | git merge # this branch should be the branch that you want to merge to the main branch 493 | ``` 494 | 495 | - By default, git will use the fast-forward merge, which means that it will move the main branch to the last commit of the new branch without creating a new commit 496 | - Other types of merge are the no-ff merge and the squash merge, and you can read more about them [here](https://git-scm.com/docs/git-merge) 497 | - If you want to create a new commit, you can use the following command: 498 | 499 | ```bash 500 | git merge --no-ff # --no-ff means no fast-forward 501 | ``` 502 | 503 | - This command will create a new commit that will contain the changes from the new branch 504 | 505 | 506 | 56. Check the readme file and you will see that the changes are there 507 | 508 | 57. Push the changes to the remote repository using the following command: 509 | 510 | ```bash 511 | git push 512 | ``` 513 | 514 | - Don't forget to put the correct branch name 515 | 516 | #### Now we'll see how to delete a branch 517 | 518 | 58. List down all the branches using the following command: 519 | 520 | ```bash 521 | git branch 522 | ``` 523 | 524 | - You should see that you are on the main branch and that you have a new branch 525 | 526 | 59. Delete the new branch using the following command: 527 | 528 | ```bash 529 | git branch -d 530 | ``` 531 | 532 | 60. List down all the branches using the following command: 533 | 534 | ```bash 535 | git branch 536 | ``` 537 | 538 | - You should see that you are on the main branch and that you don't have that branch anymore 539 | 540 | NOTE: If you want to update the remote repository with the deleted branch, you can use the following command: 541 | 542 | ```bash 543 | git push --delete # enter the name of the branch that you want to delete 544 | ``` 545 | 546 | 547 | ### Merge conflicts 548 | 549 | - Merge conflicts happen when you try to merge two branches that have different changes in the same line of the same file 550 | - You can read more about merge conflicts [here](https://www.atlassian.com/git/tutorials/using-branches/merge-conflicts) 551 | 552 | 61. Create a new branch using the following command: 553 | 554 | ```bash 555 | git checkout -b 556 | ``` 557 | 558 | 62. Add some changes to the readme file and save them 559 | 560 | 63. Check the status of the repository using the following command: 561 | 562 | ```bash 563 | git status 564 | ``` 565 | 566 | 64. Add the readme file to the staging area and commit the changes using the following commands: 567 | 568 | ```bash 569 | git add README.md 570 | git commit -m "put some changes in the readme file" 571 | ``` 572 | 573 | 65. Switch to the main branch using the following command: 574 | 575 | ```bash 576 | git checkout main 577 | ``` 578 | 579 | 66. Add some changes to the readme file and save them 580 | 581 | 67. Check the status of the repository using the following command: 582 | 583 | ```bash 584 | git status 585 | ``` 586 | 587 | 68. Add the readme file to the staging area and commit the changes using the following commands: 588 | 589 | ```bash 590 | git add README.md 591 | git commit -m "put some changes in the readme file" 592 | ``` 593 | 594 | 69. Switch to the new branch using the following command: 595 | 596 | ```bash 597 | git checkout 598 | ``` 599 | 600 | 70. Check the readme file, and you will see that both branches have different changes 601 | 602 | 71. Checkout the main branch using the following command: 603 | 604 | ```bash 605 | git checkout main 606 | ``` 607 | 608 | 74. Merge the changes from the new branch to the main branch using the following command: 609 | 610 | ```bash 611 | git merge 612 | ``` 613 | 614 | - You will get a merge conflict 615 | 616 | 75. Check the readme file, and you will see that the changes are not there 617 | 618 | 76. Check the status of the repository using the following command: 619 | 620 | ```bash 621 | git status 622 | ``` 623 | 624 | - You will see that you have a merge conflict 625 | 626 | 77. Open the readme file, and you will see that you have a merge conflict 627 | 628 | 78. How to solve a merge conflict: 629 | 630 | - You can solve a merge conflict by editing the file and removing the conflict markers ex. 631 | 632 | ```bash 633 | <<<<<< HEAD 634 | main branch changes 123 635 | ======= 636 | new branch changes one 23 637 | >>>>>> 638 | ``` 639 | 640 | - Remove the conflict markers and keep the changes that you want to keep 641 | - It should look like this (if you kept the changes from the new branch): 642 | 643 | ```bash 644 | new branch changes one 23 645 | ``` 646 | 647 | 648 | 79. Add the readme file to the staging area and commit the changes using the following commands: 649 | 650 | ```bash 651 | git add README.md 652 | git commit -m "put some changes in the readme file" 653 | ``` 654 | 655 | 80. Push the changes to the remote repository using the following command: 656 | 657 | ```bash 658 | git push 659 | ``` 660 | 661 | - Don't forget to update the branch name 662 | 663 | ### Git pull 664 | 665 | - Git pull is a combination of git fetch and git merge 666 | - Suppose that you have a local repository and a remote repository, and you made some changes to the remote repository. so, if you want to get the changes from the remote repository to the local repository 667 | 668 | 81. Use the following command: 669 | 670 | ```bash 671 | git pull 672 | ``` 673 | 674 | - This command will fetch the changes from the remote repository and merge them to the local repository 675 | 676 | #### Now we'll see git fetch and git merge 677 | 678 | 82. Create a new branch using the following command: 679 | 680 | ```bash 681 | git branch 682 | ``` 683 | 684 | 83. Check the list of branches: 685 | 686 | ```bash 687 | git branch 688 | ``` 689 | 690 | - You should see that you have a new branch but you are still on the main branch 691 | 692 | 84. Add some changes to the readme file and save them 693 | 694 | 85. Add the readme file to the staging area and commit the changes using the following commands: 695 | 696 | ```bash 697 | git add README.md 698 | git commit -m "put some changes in the readme file" 699 | ``` 700 | 701 | 86. Push the changes to the remote repository using the following command: 702 | 703 | ```bash 704 | git push 705 | ``` 706 | 707 | - Check on the GitHub website and you will see that the changes are there 708 | 709 | 87. Now switch to the new branch that you just created before: 710 | 711 | ```bash 712 | git checkout 713 | ``` 714 | 715 | 88. Run the following command to fetch the changes from the remote repository: 716 | 717 | ```bash 718 | git fetch 719 | ``` 720 | 721 | example: `git fetch origin main` 722 | 723 | - This command will fetch the changes from the remote repository, but it won't merge them to the local repository (you can check the readme file, and you will see that the changes are not there) 724 | 725 | 89. You can review the changes that you fetched from the remote repository using the following command: 726 | 727 | ```bash 728 | git checkout / 729 | ``` 730 | 731 | example: `git checkout origin/main` 732 | 733 | - This command will create a new branch that is a copy of the remote branch, and you can review the changes that you fetched from the remote repository 734 | - Note that you are on the detached HEAD state 735 | 736 | 90. If you are ok with the changes that you fetched from the remote repository, you can merge them to the local repository, but before that, switch back to the new branch that you created before: 737 | 738 | ```bash 739 | git checkout 740 | git merge / 741 | ``` 742 | 743 | example: `git merge origin/main` 744 | 745 | - This command will merge the changes to the local active branch 746 | - You can check the readme file, and you will see that the changes are there 747 | 748 | Note: a few numbers are missing, but you can still follow the tutorial 749 | 750 | ## !!! ALWAYS REMEMBER TO 'PULL' CHANGES BEFORE YOU 'PUSH' CHANGES !!! 751 | 752 | ### Git pull request 753 | 754 | - A pull request is a way to tell others about changes you've pushed to a branch in a repository on GitHub 755 | 756 | 103. Fork the repository that you want to contribute to (you can fork it from the GitHub website). 757 | 758 | 104. Clone the forked repository using the following command: 759 | 760 | ```bash 761 | git clone 762 | ``` 763 | 764 | 105. Create a new branch using the following command: 765 | 766 | ```bash 767 | git checkout -b 768 | ``` 769 | 770 | 106. Add some changes to some files and save them 771 | 772 | 107. Check the status of the repository using the following command: 773 | 774 | ```bash 775 | git status 776 | ``` 777 | 778 | 108. Add the file to the staging area and commit the changes using the following commands: 779 | 780 | ```bash 781 | git add 782 | git commit -m "put some changes in the readme file" 783 | ``` 784 | 785 | 109. Push the changes to the remote repository using the following command: 786 | 787 | ```bash 788 | git push 789 | ``` 790 | 791 | - This command will push the changes to the forked repository, not to the original repository that you forked from 792 | 793 | 110. Go to the forked repository on the GitHub website, and you will see that you have a new branch 794 | 795 | 111. Click on the 'Compare & pull request' button or 'Contribute' button 796 | 797 | 112. Add a title and a description, and click on the 'Create pull request' button 798 | 799 | 113. Check the status of the pull request, and you will see that it's waiting for approval 800 | 801 | 114. Go to the original repository on the GitHub website, and you will see that you have a new pull request 802 | 803 | Note: Only the owner of the original repository can merge the pull request 804 | 805 | 115. Click on the 'Merge pull request' button 806 | 807 | 116. Click on the 'Confirm merge' button 808 | 809 | 117. Check the status of the pull request, and you will see that it's merged 810 | 811 | 118. Go to the forked repository on the GitHub website, and you will see that the changes are there 812 | 813 | 119. If you want, you can delete the branch that you created before 814 | 815 | ### Git stash 816 | 817 | - Suppose that you have some changes that you don't want to commit, but you want to switch to another branch 818 | - You can use the stash command to save the changes and apply them later 819 | 820 | 120. Create a new branch using the following command: 821 | 822 | ```bash 823 | git checkout -b stash_test 824 | ``` 825 | 826 | 121. Add some changes to the readme file and save them 827 | 828 | 122. Add the readme file to the staging area and commit the changes using the following commands: 829 | 830 | ```bash 831 | git add README.md 832 | git commit -m "put some changes in the readme file" 833 | ``` 834 | 835 | 123. Switch to the main branch using the following command: 836 | 837 | ```bash 838 | git checkout 839 | ``` 840 | 841 | 124. Add some changes to the readme file and save them 842 | 843 | 125. Try to switch to the `stash_test` branch: 844 | 845 | - You will get an error 846 | 847 | ```bash 848 | error: Your local changes to the following files would be overwritten by checkout: 849 | README.md 850 | Please commit your changes or stash them before you switch branches. 851 | Aborting 852 | ``` 853 | 854 | 126. Use the following command to stash the changes: 855 | 856 | ```bash 857 | git stash save "" 858 | ``` 859 | 860 | 127. Now you can switch to the new branch: 861 | 862 | ```bash 863 | git checkout 864 | ``` 865 | 866 | 128. Switch back to the main branch: 867 | 868 | ```bash 869 | git checkout main 870 | ``` 871 | 872 | 129. Use the following command to list down all the stashes: 873 | 874 | ```bash 875 | git stash list 876 | ``` 877 | 878 | - If you want to see the content of any stash, 879 | ```bash 880 | git stash show -m stash@{0} # put any number @{n} from the available stash 881 | ``` 882 | 883 | 130. Use the following command to apply the changes: 884 | 885 | ```bash 886 | git stash apply 887 | ``` 888 | or 889 | 890 | - You can pop the changes using the following command: 891 | 892 | ```bash 893 | git stash pop 894 | ``` 895 | 896 | - The difference between the two commands is that the first one will apply the changes and keep the stash, and the second one will apply the changes and delete the stash 897 | 898 | 131. Delete the stash using the following command: 899 | 900 | ```bash 901 | git stash drop 902 | ``` 903 | 904 | ### Git submodules 905 | 906 | - Git submodules allow you to keep a Git repository as a subdirectory of another Git repository. 907 | - They are useful when you want to include another project inside your project. For example, a library or framework. 908 | - For example, you're developing a software framework for your custom robot and for robot perception you want to use YOLO object detection. You can create a submodule for YOLO and include it inside your project without having to copy code from YOLO to your project. 909 | 910 | 132. Create a new submodule using the following command: 911 | 912 | ```bash 913 | git submodule add 914 | ``` 915 | - This command will create a new submodule in the current directory 916 | - Check the status of the repository using `git status`, and you will see, below the list of files that need to be committed: 917 | ```bash 918 | .gitmodules 919 | 920 | ``` 921 | 922 | 133. Commit and push it to the remote repository. Check your repo on GitHub. 923 | 924 | 134. If you want to clone a project with submodules, you can use the following command: 925 | 926 | - Create a new directory 927 | - Now, clone the repo using the following command: 928 | ```bash 929 | git clone 930 | ``` 931 | 932 | - Go back and create a new directory and clone using the following command: 933 | 934 | ```bash 935 | git clone --recurse-submodules 936 | ``` 937 | - This will clone the main project and also initialize and clone any submodules. 938 | 939 | or 940 | 941 | if you forget the submodules while cloning a repo, you can later use the following command: 942 | ```bash 943 | git submodule update --init --recursive 944 | ``` 945 | 946 | 947 | 135. To update the submodule to the latest commit, 948 | ```bash 949 | git submodule update --remote 950 | ``` 951 | 952 | 136. To remove a submodule, 953 | ```bash 954 | git rm 955 | ``` 956 | Some points to note: 957 | 958 | - Submodules allow you to keep a dependency in your project repository without having unrelated history cloned. 959 | - The submodule acts like a separate repository, with its own commits, branches, etc., inside the host repository. 960 | - The host repository only stores the submodule's commit hash and not the actual code. So, to keep the main repository clean and focused on the project itself. 961 | 962 | ### GitHub Issues 963 | 964 | ### .gitignore file 965 | - The `.gitignore` file is a text file used by Git to specify files and directories that should be ignored when tracking changes in a Git repository. It's a powerful tool for controlling which files and folders are considered when making commits. 966 | - For example, while training a deep-learning model, it saves model weights files as .pth, .pkl, or .onnx, etc. Those are sometimes in MBs or GBs. To avoid pushing the model to our repo, we add them to a `.gitignore` file. 967 | - Similarly, dataset (.zip) files, binary files, temp config files, etc. 968 | 969 | ### Advance git commands 970 | 971 | - Git rebase 972 | - Used for changing the base commit of a branch 973 | - Git cherry-pick 974 | - Used for picking a commit from a branch and applying it to another branch 975 | - Git tag 976 | - Used for marking a specific commit with a tag 977 | 978 | 979 | ### Small Git quiz 980 | 981 | 1. You and your team are working on a project using Git. One of your team members has made some changes to a file, but they're not sure if they want to keep them or not. What Git command can they use to see the changes they've made and decide whether to keep them? 982 | 983 | - Answer: `git diff `, similar to [#36](https://github.com/kvnptl/practice_git/tree/main#:~:text=Now%20we%27ll%20see%20how%20to%20compare%20the%20changes%20between%20two%20commits) 984 | 985 | 2. You've been working on a project using Git, and you accidentally deleted a file that was important. What command can you use to restore the file to the state it was in before it was deleted? 986 | 987 | - Answer: `git checkout -- ` 988 | 989 | 3. You've been working on a feature branch in Git, and you're ready to merge your changes back into the main branch. What command should you use to create a new merge commit that incorporates your changes? 990 | 991 | - Answer: `git merge ` from the branch you want to merge into (e.g. `git merge feature` from the main branch) 992 | 993 | 4. You're working on a project using Git and have made changes to multiple files. Now, you want to commit only specific changes and not all of them. What command can you use to do this? 994 | 995 | - Answer: `git add ` 996 | 997 | 5. You're working on a project using Git, and you want to see a list of all the commits that have been made to the repository. What command can you use to see this list? 998 | 999 | - Answer: `git log` 1000 | 1001 | 6. Your team is working on a project using Git, and you want to make sure that everyone is using the latest version of the code. What command can you use to update your local repository with the latest changes from the remote repository? 1002 | 1003 | - Answer: `git pull ` 1004 | 1005 | 7. Your team is working on a project using Git, and you want to create a new branch to work on a new feature. What command can you use to create a new branch? 1006 | 1007 | - Answer: `git checkout -b ` 1008 | 1009 | 8. You're actively involved in a collaborative project using Git, and you're currently working on a feature branch. However, it's still a work in progress. At this point, your project manager requests you to begin working on a completely new feature, Feature 2. What would be the recommended course of action in this situation? 1010 | 1011 | - Answer: `git stash save "some msg for pending work in feature branch"` 1012 | 1013 | ### Some online resources 1014 | 1015 | - Github | [Git cheat sheet](https://education.github.com/git-cheat-sheet-education.pdf) 1016 | - Atlassian | [Git cheat sheet](https://www.atlassian.com/git/tutorials/atlassian-git-cheatsheet) 1017 | - Udacity course | [Version Control with Git](https://www.udacity.com/course/version-control-with-git--ud123) 1018 | - Atlassian | Coursera course: [Version Control with Git](https://www.coursera.org/learn/version-control-with-git#syllabus) 1019 | - Free Code Camp | [Git and GitHub for Beginners - Crash Course](https://youtu.be/RGOj5yH7evk) 1020 | - IBM edx course: [Introduction to git and github](https://www.edx.org/course/introduction-to-git-and-github) 1021 | 1022 | ## Small projects for practice 1023 | 1024 | **1. Project title: Calculator Application with Git and Version Control** 1025 | 1026 | Description: Create a calculator application using Python and use Git and GitHub for version control 1027 | 1028 | No. of students: 3 1029 | 1030 | Time: 2 hours 1031 | 1032 | Start with 1033 | 1034 | - Only one student should fork this repository: [fc-ss23-git](https://github.com/kvnptl/fc-ss23-git) 1035 | - Add the other 2 students as collaborators to the repository (On GitHub, go to Settings > Collaborators > Add people) 1036 | - Everyone should clone the forked repository 1037 | - Each student should create a new branch for his/her task 1038 | - Work on the `calculator_application.py` file 1039 | 1040 | Tasks: 1041 | - Create the first commit for your task description only 1042 | - Develop a separate function for each functionality 1043 | - The code should take user input(if applicable) and display the result 1044 | - After completing the task, create a pull request to the `fc-ss23-git` repository's `main` branch 1045 | 1046 | 1047 | Student 1 1048 | - Arithmetic operations (addition, subtraction, multiplication, division) 1049 | - Trigonometric operations (sin, cos, tan) 1050 | 1051 | Student 2 1052 | - Logarithmic operations (log, ln) 1053 | - Exponential operations (exp, sqrt) 1054 | - Degree to radian conversion, radian to degree conversion 1055 | 1056 | Student 3 1057 | - Area of a circle, area of a triangle, area of a rectangle 1058 | - Volume of a sphere, volume of a cylinder, volume of a cone 1059 | - Find pythagorean triplets 1060 | 1061 | **2. Project title: IRIS data plotting with Git and Version Control** 1062 | 1063 | Download dataset: [Iris dataset](https://archive.ics.uci.edu/ml/datasets/iris) 1064 | 1065 | Description: Create a data plotting application using Python and use Git and GitHub for version control 1066 | 1067 | No. of students: 3 1068 | 1069 | Time: 2 hours 1070 | 1071 | Start with: 1072 | 1073 | - Only one student should fork this repository: [fc-ss23-git](https://github.com/kvnptl/fc-ss23-git) 1074 | - Add the other 2 students as collaborators to the repository (On GitHub, go to Settings > Collaborators > Add people) 1075 | - Everyone should clone the forked repository 1076 | - Each student should create a new branch for his/her task 1077 | - Work on the `iris_data_plotting.py` file 1078 | 1079 | Tasks: 1080 | 1081 | - Create the first commit for your task description only 1082 | - Develop a separate function for each functionality 1083 | - The code should take user input(if applicable) and display the result 1084 | - After completing the task, create a pull request to the `fc-ss23-git` repository's `main` branch 1085 | 1086 | Student 1 1087 | - Plot the data using a scatter plot 1088 | - Plot the data using a line plot 1089 | - Find the mean, median, mode, standard deviation, variance, and range of the data 1090 | 1091 | Student 2 1092 | - Plot the data using a bar plot 1093 | - Plot the data using a histogram 1094 | 1095 | Student 3 1096 | - Plot the data using a box plot 1097 | - Plot the data using a violin plot 1098 | 1099 | 1100 | **3. Project title: Basic image processing application with Git and Version Control** 1101 | 1102 | Requirements: 1103 | - Python 1104 | - OpenCV 1105 | - Numpy 1106 | 1107 | Description: Create a basic image processing application using Python and use Git and GitHub for version control 1108 | 1109 | Resources: find sample images [here](https://github.com/kvnptl/fc-ss23-git/tree/main/basic_image_processing/images) 1110 | 1111 | No. of students: 3 (group 1) 1112 | 1113 | No. of students: 3 (group 2) 1114 | 1115 | Time: 2 hours 1116 | 1117 | Start with: 1118 | 1119 | - Only one student should fork this repository: [fc-ss23-git](https://github.com/kvnptl/fc-ss23-git) 1120 | - Add the other 2 students as collaborators to the repository (On GitHub, go to Settings > Collaborators > Add people) 1121 | - Everyone should clone the forked repository 1122 | - Each student should create a new branch for his/her task 1123 | - Work on the `basic_image_processing_application.py` file 1124 | 1125 | Tasks: 1126 | 1127 | - Create the first commit for your task description only 1128 | - Develop a separate function for each functionality 1129 | - The code should take user input(if applicable) and display the result 1130 | - After completing the task, create a pull request to the `fc-ss23-git` repository's `main` branch 1131 | 1132 | Student 1 1133 | - Read an image 1134 | - Display the image 1135 | - Save the image 1136 | - Convert the image to grayscale 1137 | - Convert the image to binary 1138 | - Convert the image to HSV 1139 | 1140 | Student 2 1141 | 1142 | - Read an image 1143 | - Display the image 1144 | - Save the image 1145 | - Resize the image 1146 | - Crop the image 1147 | - Rotate the image 1148 | 1149 | Student 3 1150 | - Read an image 1151 | - Display the image 1152 | - Save the image 1153 | - Blur the image 1154 | - Sharpen the image 1155 | - Edge detection 1156 | 1157 | 1158 | **4. Project title: validating credit card numbers with Git and Version Control** 1159 | 1160 | Description: Create a program to validate credit card numbers using Python and use Git and GitHub for version control 1161 | 1162 | Resources: find the instructions [here](https://github.com/kvnptl/fc-ss23-git/blob/main/validating_credit_card_numbers/instructions/validating_credit_card_numbers.pdf) 1163 | 1164 | No. of students: 2 1165 | 1166 | Time: 2 hours 1167 | 1168 | Start with: 1169 | 1170 | - Only one student should fork this repository: [fc-ss23-git](https://github.com/kvnptl/fc-ss23-git) 1171 | - Add the other 2 students as collaborators to the repository (On GitHub, go to Settings > Collaborators > Add people) 1172 | - Everyone should clone the forked repository 1173 | - Each student should create a new branch for his/her task 1174 | - Work on the `validating_credit_card_numbers.py` file 1175 | 1176 | Tasks: 1177 | 1178 | - Create the first commit for your task description only 1179 | - Develop a separate function for each functionality 1180 | - The code should take user input(if applicable) and display the result 1181 | - After completing the task, create a pull request to the `fc-ss23-git` repository's `main` branch 1182 | 1183 | Student 1 & 2: divide the check conditions into two parts 1184 | 1185 | **5. Project title: Validating email addresses with Git and Version Control** 1186 | 1187 | Description: Create a program to validate email addresses using Python and use Git and GitHub for version control 1188 | 1189 | Resources: find the instructions [here](https://github.com/kvnptl/fc-ss23-git/blob/main/validating_email_addresses/instructions/validating_email_addresses.pdf) 1190 | 1191 | No. of students: 2 1192 | 1193 | Time: 2 hours 1194 | 1195 | Start with: 1196 | 1197 | - Only one student should fork this repository: [fc-ss23-git](https://github.com/kvnptl/fc-ss23-git) 1198 | - Add the other 2 students as collaborators to the repository (On GitHub, go to Settings > Collaborators > Add people) 1199 | - Everyone should clone the forked repository 1200 | - Each student should create a new branch for his/her task 1201 | - Work on the `validating_email_addresses.py` file 1202 | 1203 | Tasks: 1204 | 1205 | - Create first commit for your task description only 1206 | - Develop a separate function for each functionality 1207 | - The code should take user input(if applicable) and display the result 1208 | - After completing the task, create a pull request to the `fc-ss23-git` repository's `main` branch 1209 | 1210 | Student 1 & 2: divide the check conditions into two parts 1211 | --------------------------------------------------------------------------------