|
1 |
| -## Presentation |
2 |
| -https://gitpitch.com/devopsacademyau/academy?p=/classes/01class/git#/ |
| 1 | +#### Presentation URL: https://gitpitch.com/devopsacademyau/academy?p=classes/01class/git/ |
| 2 | + |
| 3 | +# Let's Get **Started** with Git |
| 4 | + |
| 5 | +--- |
| 6 | +### Versioning: The "old way" |
| 7 | + |
| 8 | +- Pessimistic locking, code duplication |
| 9 | + - Local versioning -> Copy and paste (Let's duplicate!) |
| 10 | + - Version overwriting (Who deleted my version!?) |
| 11 | + - Locked file (Can you please release file customers.xls, please!?) |
| 12 | +- Are there other problems? |
| 13 | + |
| 14 | + |
| 15 | +--- |
| 16 | +### What is Git? |
| 17 | + |
| 18 | +- Created by Linus Torvalds in 2005 for development of the Linux kernel |
| 19 | +- Git is a distributed VCS |
| 20 | +- Centralized vs Distributed VCS? |
| 21 | +- Optimistic vs Pessimistic locking? |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +### Centralised vs Distributed VCS |
| 29 | + |
| 30 | +- Centralised: |
| 31 | + - Centralised master version |
| 32 | + - Code Check outs (one developer is allowed to work on that part of the code at any one time.) |
| 33 | + - Locking controlled by the server |
| 34 | + - Release records version numbers of all elements |
| 35 | +- Distributed: |
| 36 | + - Entire history of changes cloned by developers |
| 37 | + - No locking |
| 38 | + - Changes modify history (append or rewrite) |
| 39 | + - Release is a history of changes |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +### Optimistic Locking |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +So, how git achieves optimistic locking so developers can work in parallel in the same file? |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +### Git Storage |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +### Git Main Commands |
| 61 | + |
| 62 | +- start a working area (see also: git help tutorial) |
| 63 | + - **clone** Clone a repository into a new directory |
| 64 | + - **init** Create an empty Git repository or reinitialize an existing one |
| 65 | + |
| 66 | +- work on the current change (see also: git help everyday) |
| 67 | + - **add** Add file contents to the index |
| 68 | + - **mv** Move or rename a file, a directory, or a symlink |
| 69 | + - **reset** Reset current HEAD to the specified state |
| 70 | + - **rm** Remove files from the working tree and from the index |
| 71 | + |
| 72 | +- examine the history and state (see also: git help revisions) |
| 73 | + - **bisect** Use binary search to find the commit that introduced a bug |
| 74 | + - **grep** Print lines matching a pattern |
| 75 | + - **log** Show commit logs |
| 76 | + - **show** Show various types of objects |
| 77 | + - **status** Show the working tree status |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +### Git Main Commands (more) |
| 82 | + |
| 83 | +- grow, mark and tweak your common history |
| 84 | + - **branch** List, create, or delete branches |
| 85 | + - **checkout** Switch branches or restore working tree files |
| 86 | + - **commit** Record changes to the repository |
| 87 | + - **diff** Show changes between commits, commit and working tree, etc |
| 88 | + - **merge** Join two or more development histories together |
| 89 | + - **rebase** Reapply commits on top of another base tip |
| 90 | + - **tag** Create, list, delete or verify a tag object signed with GPG |
| 91 | + |
| 92 | +- collaborate (see also: git help workflows) |
| 93 | + - **fetch** Download objects and refs from another repository |
| 94 | + - **pull** Fetch from and integrate with another repository or a local branch |
| 95 | + - **push** Update remote refs along with associated objects |
| 96 | + |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +### Let's do it together |
| 101 | +Let's add a folder to hold exercises for classes |
| 102 | + |
| 103 | +1. Check README.md in the root for instructions. |
| 104 | +2. Add, commit and push it to your remote dev branch :tada: |
| 105 | +3. Create a Pull Request (PR) |
| 106 | + |
| 107 | + |
| 108 | +--- |
| 109 | + |
| 110 | +### Checking in code can get complex (quickly!) |
| 111 | + |
| 112 | + |
| 113 | +How can we have a standard approach to work as one team? |
| 114 | + |
| 115 | +--- |
| 116 | +### A solution: Trunk based development |
| 117 | + |
| 118 | +Short lived branches simplify a lot of things! |
| 119 | +https://trunkbaseddevelopment.com/ |
| 120 | + |
| 121 | +[See also GitFlow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) |
| 122 | +--- |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | +--- |
| 127 | + |
| 128 | +### Merging vs Rebasing |
| 129 | + |
| 130 | +`git checkout feature` |
| 131 | +`git merge master` |
| 132 | + |
| 133 | + |
| 134 | +`git checkout feature` |
| 135 | +`git rebase master` |
| 136 | + |
| 137 | + |
| 138 | +--- |
| 139 | + |
| 140 | +## What is the problem of re-writing the history with **git rebase**? |
| 141 | + |
| 142 | +--- |
| 143 | + |
| 144 | +### Let's do it together - Exercise |
| 145 | + |
| 146 | +**Merging and Rebasing** |
| 147 | +1. Access https://learngitbranching.js.org/ |
| 148 | +2. Merging exercise: |
| 149 | + 1. type `level intro3` |
| 150 | +3. Rebasing exercise: |
| 151 | + 1. type `level intro4` |
| 152 | + |
| 153 | +--- |
| 154 | + |
| 155 | +**OMG, I don't know what I did!** |
| 156 | + |
| 157 | +https://ohshitgit.com/ |
| 158 | + |
| 159 | +--- |
| 160 | + |
| 161 | +### References |
| 162 | + |
| 163 | +1. https://martinfowler.com/eaaCatalog/optimisticOfflineLock.html |
| 164 | +1. https://www.teamstudio.com/blog/distributed-vs-centralized-version-control-systems-for-lotus-notes |
| 165 | +1. https://www.atlassian.com/git/tutorials/merging-vs-rebasing |
0 commit comments