Submodules

How to properly remove submodule from git:

  1. Remove the submodule entry from .git/config
    git submodule deinit -f path/to/submodule
  2. Remove the submodule directory from the superproject’s .git/modules directory
    rm -rf .git/modules/path/to/submodule
  3. Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule
    git rm -f path/to/submodule

Pull git submodules (ie fill directories) once you have pulled a repo, remote to local

  1. in root directory, git submodule init
  2. git submodule update

Update a submodule in Hugo Blog:

  1. (optional–only for forked submodules) update your main repo and push to github per usual
  2. in Hugo project, go into themes/ and run a git fetch and git merge origin/main
  3. return to root folder, commit and push per usual.

General

Force pull (overide) local git with remote repo

  1. git fetch --all
  2. git reset --hard origin/master (can also replace ‘master’ with another branch)

Rollback to a specific commit:
git reset --hard <old-commit-id> (first 6 alphanum)
git push -f <remote-name> <branch-name>

Start a fresh local repo with remote github repo:

  1. create folder structure, including the root folder of your directory
  2. cd into root
  3. git init
  4. git remote add origin git@github.com:user/repo.git
  5. git pull origin master

Create a new local branch from master, then push to new remote branch:

  1. git checkout -b newbranch
  2. make change, add file, etc
  3. git add . ; git commit -m "first commit newbranch" ; git push origin newbranch

Check recent commits: git log
Escape list of commits: q

Awesome resources: