├── LICENSE
├── README.md
└── README.pt.md
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Gabriel de Jesus
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
22 | English | 23 | Português 24 |
25 | 26 | - Starting a Repository 27 | 28 | `git init` 29 | 30 | --- 31 | 32 | - Listing Modified Files 33 | 34 | `git status` 35 | 36 | --- 37 | 38 | - Undoing Changes 39 | 40 | - Unmonitored files 41 | 42 | `git checkout` 43 | 44 | - To delete new files that have not yet been added to the Stage 45 | 46 | `git clean -df` 47 | 48 | - Removing files from the Stage 49 | 50 | `git reset` 51 | 52 | - Undoing the last commit 53 | 54 | `git revert HEAD` 55 | 56 | --- 57 | 58 | - Rename Commit 59 | 60 | `git commit —amend` 61 | 62 | --- 63 | 64 | - Branches 65 | 66 | - Listing local Branches 67 | 68 | `git branch` 69 | 70 | - Also list the branches that are in the remote repository 71 | 72 | `git branch -a` 73 | 74 | - Going to another branch 75 | 76 | `git checkout my-branch` 77 | 78 | - If you add -b a new branch will be created 79 | 80 | `git checkout -b my-new-branch` 81 | 82 | - Excluding branches 83 | 84 | `git branch -d branch-name // normal` 85 | 86 | `git branch -D branch-name // forcing` 87 | 88 | - Renaming branches 89 | 90 | `git branch -m new-branch-name` 91 | 92 | - If you are on a branch and want to rename another one, you must first pass the current name of the branch you want to rename: 93 | 94 | `git branch -m current-name new-name` 95 | 96 | - Orphan Branch 97 | An orphaned branch has this name because it is not linked to the main branch, so 98 | their histories are not shared. 99 | 100 | ```shell 101 | Example: 102 | i --- j --- k <== branch 'my branch' 103 | / 104 | a --- b --- c --- d --- h --- l <== branch 'main' 105 | \ / 106 | and --- f --- g <== branch 'my other branch' 107 | 108 | 1 --- 2 --- 3 --- 4 <== `orphaned 'branch 109 | ``` 110 | 111 | This can be useful when you want to place more than one project in the same 112 | repository. A good example is when you have a project on Github and want to create 113 | a website to publicize your project. The application and the website are different things, 114 | therefore, their codes must be versioned separately. 115 | Having both in the same repository simplifies management. 116 | 117 | To create an orphaned branch just use the command: 118 | 119 | `git checkout --orphan my-branch-orphan` 120 | 121 | --- 122 | 123 | - Viewing Commit History 124 | 125 | `git log` 126 | 127 | - History of one or more files 128 | 129 | `git log -p my-files` 130 | 131 | - Author's history 132 | 133 | `git log --author = name-author` 134 | 135 | - History by date 136 | 137 | `git log --after = "MMM DD YYYY"` 138 | 139 | `git log --before = "MMM DD YYYY"` 140 | 141 | - History Based on a message (commit) 142 | 143 | `git log --grep products` 144 | 145 | With this command we will have the history of commits in which the commit message 146 | has the word “products”. What we go through can be a regular expression, 147 | and we can spend more than one: 148 | 149 | Examples: 150 | 151 | Search for "products" OR "users" 152 | 153 | `git log --grep products --grep users` 154 | 155 | Search for "products" AND "users" 156 | 157 | `git log --grep products --and --grep users` 158 | 159 | --- 160 | 161 | - Display branches in a more readable mode 162 | 163 | It is possible to have the history printed showing the branches of the repository with something 164 | more readable and in color with a command. We will have a result similar to this: 165 | 166 | ```shell 167 | * a102055 (HEAD -> master) commit 8 168 | | * 196d28e (branch-2) commit 7 169 | | * 07e073c commit 3 170 | | * 2b077ca new fie 171 | | | * c1369d8 (branch-3) commit 6 172 | | | * d11bdcd commit 5 173 | | | / 174 | | / | 175 | * | 2b22b75 commit 2 176 | | / 177 | * d5a12b0 .gitignore 178 | * 9535426 - commit 1 179 | ``` 180 | 181 | The command is a little long: 182 | 183 | `git log --all --decorate --oneline --graph` 184 | 185 | To decorate everything we should write after the log. 186 | 187 | ``` 188 | --all 189 | --decorate 190 | --oneline 191 | --graph 192 | ``` 193 | 194 | --- 195 | 196 | - Working on more than one thing without committing 197 | 198 | There may be times when you need to stop what you are doing and start working 199 | in another task. However, it may not be good to commit something that has not yet been 200 | finalized and then return to it, resulting in a commit that will be in the history 201 | but it has code that doesn't work. We can save these changes made 202 | even without having to perform a commit to later work on it again, which is 203 | called a Stash (something like "hide" or "accumulate"). 204 | 205 | By doing this, your repository will return to the state of the last commit, and the changes 206 | previously made will be “hidden”. 207 | 208 | - Saving changes to a Stash 209 | 210 | `git stash` 211 | 212 | - You can still put a name on this stash 213 | 214 | `git stash push -m my-name-stash` 215 | 216 | - Listing Stash 217 | 218 | `git stash list` 219 | 220 | - Recovering modifications 221 | 222 | `git stash apply` 223 | 224 | This will retrieve the most recent stash code. If you want to recover a stash 225 | oldest, just look at the number of the stash that appears when we list it and pass 226 | for the following command: 227 | 228 | `git stash apply stash @ {2}` 229 | 230 | - Removing Stashes 231 | 232 | When we retrieve changes from a stash, it remains saved. To delete it 233 | from the stack, run the drop command next to the name of the stash you want to remove 234 | 235 | `git stash drop stash @ {5}` 236 | 237 | --- 238 | -------------------------------------------------------------------------------- /README.pt.md: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |