|
5 | 5 | ### Ignore files
|
6 | 6 | - Add those files to `.gitignore`
|
7 | 7 | - To use specific template for specific project, take a look at https://github.com/github/gitignore
|
| 8 | +- Nice .gitignore generators: |
| 9 | + - https://github.com/simonwhitaker/gibo |
| 10 | + - https://www.toptal.com/developers/gitignore/ |
| 11 | + |
| 12 | +### Global .gitignore |
| 13 | +- Reason to why we need a global .gitignore: Local .gitignore should be used for objects that should not be versioned, but still within the scope of the repo. In the case of system-specific files, it's a good practice to use global .gitignore. |
| 14 | +- Solution: |
| 15 | + - [RECOMMEND] the conventional global .gitignore file is `~/.config/git/ignore` |
| 16 | + - [OLD_SOLUTION] create a .gitignore file and attach it with git |
| 17 | + - Step 1: Create a new .gitignore file in anywhere you want |
| 18 | + |
| 19 | + ```bash |
| 20 | + touch ~/.gitignore |
| 21 | + ``` |
| 22 | + |
| 23 | + - Step 2: attach that file with git's global settings |
| 24 | + |
| 25 | + ```bash |
| 26 | + git config --global core.excludesfile ~/.gitignore |
| 27 | + ``` |
| 28 | + |
| 29 | + - You can verify the global .gitignore location by `git config --global core.excludesFile` |
| 30 | +- A nice global .gitignore template: https://github.com/github/gitignore/tree/main/Global |
| 31 | + |
| 32 | +- References: |
| 33 | + - https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files#configuring-ignored-files-for-all-repositories-on-your-computer |
| 34 | + - https://gist.github.com/subfuzion/db7f57fff2fb6998a16c |
8 | 35 |
|
9 | 36 | ### Share git hooks with team
|
10 | 37 | - Reason: git hooks stay in `.git`, hence not pushed to remote repository -> got to find a workaround to share these hooks with team
|
11 |
| -- Solution: create a folder called `scripts` or `.githooks` or `git-scripts` (or any name you want) in your local repo, and use |
| 38 | +- Solution: create a folder called `scripts` or `.githooks` or `git-scripts` (or any name you want) in your local repo, and use one of these methods: |
12 | 39 | - [RECOMMEND] config hooks path with
|
13 | 40 |
|
14 | 41 | ```bash
|
|
21 | 48 | ln -s <folder_name> ".git/hooks"
|
22 | 49 | ```
|
23 | 50 | - SUPER TIP: Automate the sharing process by putting any githook setup to a script and ask your team to run it. Example:
|
24 |
| - |
| 51 | +`` |
25 | 52 | ```bash
|
26 | 53 | #!/bin/bash
|
27 | 54 |
|
|
230 | 257 | - Reference: https://opensource.com/article/20/10/advanced-git-tips
|
231 | 258 |
|
232 | 259 | ## TODO
|
233 |
| -- revert a commit by hash |
234 | 260 | - cherry pick
|
235 |
| -- global gitignore |
236 | 261 | - write a script to prepare tips needed for a project, e.g., prepare githooks, config aliases
|
237 | 262 |
|
238 | 263 | - Ref:
|
|
0 commit comments