# [[Ignoring files in Git]] ![[Ignoring files in Git.svg]] You might not always want to track changes to all files in a repository. For example, if you have files that store access tokens, passwords, or other sensitive information specific to your copy of the code, you wouldn't want to push that back to a public remote. [[Git]] allows you to set a list for files to ignore when tracking changes. Where you create this list depends on whether you want git to ignore those files for only the current local repo, all local repos, your remote repo, or some combination of those. ## Ignore on remote and local repo ### .gitignore In the repo directory, add any files you want Git to ignore in `.gitignore` and save it. ``` # macOS system files .DS_Store # IDE files .vscode/ .idea/ # Python cache __pycache__/ *.pyc # Node node_modules/ ``` ### Remove ignored files from the repository In some cases, you might have already added the files to the repository, so simply adding them to `.gitignore` is not enough. You'll need to run this command as well: `git rm -rf --cached filename` or `git rm -rf --cached folder` ### Add back the files to staging Then, you should be able to run `git add .`. Verify with `git status` that the files you added to `.gitignore` were not staged. ### Ignore changes in file locally, but keep it in GitHub `git update-index --assume-unchanged filename` ## Ignore for remote repo ## Global ignore on local machine If you want to set up a global ignore file that is respected for all git repos on your local machine, set up global git exclude file at `~/.gitignore_global` (you can change the name) and add the file/path/pattern there that you want to be ignored just like you would in a [[Ignoring files in Git#.gitignore]] Then, configure git to use the global exclude file: ```bash git config --global core.excludesfile ~/.gitignore_global ``` ## References - https://stackoverflow.com/questions/25436312/gitignore-not-working ## See also - [[Branching in Git]] - [[Viewing a PR locally in Git]] %% # Excalidraw Data ## Text Elements ## Drawing ```json { "type": "excalidraw", "version": 2, "source": "https://github.com/zsviczian/obsidian-excalidraw-plugin/releases/tag/2.1.4", "elements": [ { "id": "4y8R7iOA", "type": "text", "x": 118.49495565891266, "y": -333.44393157958984, "width": 3.8599853515625, "height": 24, "angle": 0, "strokeColor": "#1e1e1e", "backgroundColor": "transparent", "fillStyle": "solid", "strokeWidth": 2, "strokeStyle": "solid", "roughness": 1, "opacity": 100, "groupIds": [], "frameId": null, "roundness": null, "seed": 967149026, "version": 2, "versionNonce": 939059582, "isDeleted": true, "boundElements": null, "updated": 1713723615080, "link": null, "locked": false, "text": "", "rawText": "", "fontSize": 20, "fontFamily": 4, "textAlign": "left", "verticalAlign": "top", "containerId": null, "originalText": "", "lineHeight": 1.2 } ], "appState": { "theme": "dark", "viewBackgroundColor": "#ffffff", "currentItemStrokeColor": "#1e1e1e", "currentItemBackgroundColor": "transparent", "currentItemFillStyle": "solid", "currentItemStrokeWidth": 2, "currentItemStrokeStyle": "solid", "currentItemRoughness": 1, "currentItemOpacity": 100, "currentItemFontFamily": 4, "currentItemFontSize": 20, "currentItemTextAlign": "left", "currentItemStartArrowhead": null, "currentItemEndArrowhead": "arrow", "scrollX": 583.2388916015625, "scrollY": 573.6323852539062, "zoom": { "value": 1 }, "currentItemRoundness": "round", "gridSize": null, "gridColor": { "Bold": "#C9C9C9FF", "Regular": "#EDEDEDFF" }, "currentStrokeOptions": null, "previousGridSize": null, "frameRendering": { "enabled": true, "clip": true, "name": true, "outline": true } }, "files": {} } ``` %%