Line 140: |
Line 140: |
|   OR <br> | |   OR <br> |
| <b>git add -u</b> <br> | | <b>git add -u</b> <br> |
− | <  <i> - Adds modified and deleted files only. Excludes new files. It will include files in the current directory and in higher directories that belong to the same git repository</i><br><br> | + |   <i> - Adds modified and deleted files only. Excludes new files. It will include files in the current directory and in higher directories that belong to the same git repository</i><br><br> |
| For a more detailed description of <i>git add</i> go to: https://github.com/git-guides/git-add</li><br> | | For a more detailed description of <i>git add</i> go to: https://github.com/git-guides/git-add</li><br> |
| | | |
Line 166: |
Line 166: |
|   You can now continue to code and push/pull to GitHub as needed to track/update changes. Good luck, if it doesn't work don't blame me ... I only work here :) </li><br> | |   You can now continue to code and push/pull to GitHub as needed to track/update changes. Good luck, if it doesn't work don't blame me ... I only work here :) </li><br> |
| </ol> | | </ol> |
| + | |
| + | == <i>Ignoring Files (.gitignore)</i> == |
| + | There are various reasons to not want to track/push files. The following situation helps when you're having trouble pushing files due to them being too big (>50 MB, GitHub max) . |
| + | <ol> |
| + | <li><u>Find those problem files</u>: <br> |
| + |   - Ensure you're in the directory of interest (use <b>cd </b> command as needed) <br> |
| + |   - Type <b>find . -type f -size +50M </b><br> |
| + |   - This will list files that are above GitHub's 50 MB limit </li><br> |
| + | |
| + | <li><u>Create a .gitignore file</u>: <br> |
| + |   - To create one use the command <b>touch .gitnore </b><br> |
| + |     Make sure you are in the root folder of your repository on your local computer when you use this command <br> |
| + |     <u>Hint</u> - The root folder is named the same as your repository on GitHub </li><br> |
| + | |
| + | <li><u>Use your favorite text editor to open the file (i.e. Vim, Notepad++, etc.)</u>: <br> |
| + |   - Enter the oversized files from above into the girignore file<br> |
| + |     Make sure to remove the <b>.</b> if you decide to copy/paste <br> |
| + | <i><u>Example</u>:</i></li> |
| + | |
| + | <!-- Example --> |
| + | <pre># Remember: A line that follows # is a comment. |
| + | # |
| + | # To ignore a file update this file (.gitignore) then add, commit, and push this file. |
| + | # Do this BEFORE any other pushes so the rule will be in effect. |
| + | |
| + | # These files are above GitHub's recommended file size (50 MB). SUBFOLDER/FILE |
| + | MonteCarlo/fermi.txt |
| + | Examples/mctuple.root |
| + | Examples/mctuple.hbook |
| + | Examples/ntuple.root |
| + | Examples/log |
| + | Examples/omega2p_sim_1.itape |
| + | Examples/ntuple.hbook |
| + | |
| + | # These are object files. Code that is compiled to machine code, no need fo me to saved/tracked in GitHub. |
| + | # * is a wild card, so anything that has .o at the end is ignored using *.o, while *.o.* says ignore anything that has .o. within the name. |
| + | *.o |
| + | *.o.* |
| + | </pre><br> |
| + | |
| + | <li><u>Ignore already checked in files</u>: <br> |
| + |   - Since you already tried and failed to fully push those file, you'll need to untrack them <br> |
| + |   - From your terminal type <b>git rm --cached FILENAME </b><br> |
| + |     Hint - You can copy/paste from the find results <b>git rm --cached /SUBFOLDER/FILENAME </b><br> |
| + |   - Do this for all files that require it before proceeding </li><br> |
| + | |
| + | <li><u>Add, commit, and push the .gitignore file</u>: <br> |
| + |   - Add the gitignore file using <b>git add .gitignore </b> <br> |
| + |   - Commit the file using <b>git commit -m "Files to ignore" </b> <br> |
| + |   - Push the commit using <b>git push origin main </b> <br> |
| + |     Now subsequent pushes will know to ignore those files or types of files </li> <br> |
| | | |
| == <u><i>Extras</i></u> == | | == <u><i>Extras</i></u> == |