• Reset a file from a particular branch:
git checkout main -- $FILENAME
  • Merge to local branch source:
git checkout main
git pull
git checkout $BRANCH
git merge main
git push
  • Similar merge, but not update local main:
git checkout $BRANCH
git merge origin/main
git push
  • Rebase a branch back to main, deleting all local changes
git reset --hard origin/main

Git Submodules

  • Reference: https://devconnected.com/how-to-add-and-update-git-submodules/

  • Create submodule

git submodule add $GIT_REPO $SUB_MODULE_FOLDER
  • Update a submodule
git submodule update --remote --merge
  • Clone a repo with submodules
git clone --recurse-submodules $GIT_REPO