Git & Github - NOAA-EDAB/seaside GitHub Wiki

Git and Github workflow

Useful info from the Ocean Health Index blog.

Github

Beginner course

Tips for GitHub 2 factor authentication

Committing to github from the container

  • Create a personal access token as described above
  • Initiate the commit from the container
  • Enter your github username when prompted
  • When prompted for your password, enter your token instead of your github password

Troubleshooting git

Cleaning up your .git folder (using the terminal)

  • Quick clean: run git gc
  • In-depth cleaning:
    • Run git gc as a first pass
    • Check if any deleted branches are still listed in the packed-refs file in the .git folder
    • If so, delete the lines of the pack file containing the deleted branches' names
    • Run git reflog expire --all --expire=now
    • Run git gc --prune=now --aggressive
    • Admire how much space you have freed up on your computer

What to do if you accidentally commit a file that is too large (>100MB)

  • open terminal
  • navigate to git directory (DIR on Windows, ls on Mac)
  • run git reset --soft HEAD~1
  • this undoes your last commit
  • remove the large file from your commit (add to gitignore) and re-commit

If you accidentally commit a bunch of files to the wrong branch (ex, with Github Actions)

  • Run git push -f origin HEAD^:main (or whichever branch you made the mistake on)
  • This undoes the most recent commit on the remote and locally.
  • The commit is entirely gone. You can't recover it. Beware!

Misc

Videos