Changes

Jump to navigation Jump to search
2,711 bytes added ,  21:21, 5 June 2023
Line 140: Line 140:  
       &emsp; OR <br>
 
       &emsp; OR <br>
 
       <b>git add -u</b> <br>
 
       <b>git add -u</b> <br>
       <&ensp; <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>
+
       &ensp; <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:  
       &emsp; &nbsp; 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>
 
       &emsp; &nbsp; 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>
 +
      &ensp; - Ensure you're in the directory of interest (use <b>cd </b> command as needed) <br>
 +
      &ensp; - Type <b>find . -type f -size +50M </b><br>
 +
      &ensp; - This will list files that are above GitHub's 50 MB limit </li><br>
 +
 +
  <li><u>Create a .gitignore file</u>: <br>
 +
      &ensp; - To create one use the command <b>touch .gitnore </b><br>
 +
      &ensp; &ensp; Make sure you are in the root folder of your repository on your local computer when you use this command <br>
 +
      &ensp; &ensp; <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>
 +
      &ensp; - Enter the oversized files from above into the girignore file<br>
 +
      &ensp; &ensp; 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>
 +
      &ensp; - Since you already tried and failed to fully push those file, you'll need to untrack them <br>
 +
      &ensp; - From your terminal type <b>git rm --cached FILENAME </b><br>
 +
      &ensp; &ensp; Hint - You can copy/paste from the find results <b>git rm --cached /SUBFOLDER/FILENAME </b><br>
 +
      &ensp; - Do this for all files that require it before proceeding </li><br>
 +
 +
  <li><u>Add, commit, and push the .gitignore file</u>: <br>
 +
      &ensp; - Add the gitignore file using <b>git add .gitignore </b> <br>
 +
      &ensp; - Commit the file using <b>git commit -m "Files to ignore" </b> <br>
 +
      &ensp; - Push the commit using <b>git push origin main </b> <br>
 +
      &ensp; &ensp; 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> ==
581

edits

Navigation menu