git pull fetch rebase
git pull --rebase|-r # Normal to avoid merge commits. git pull --rebase=preserve # When local merge commit preserved, like Pull Request. git config --global pull.rebase preserve # if you're on Git 2.18 or later git pull --rebase=merges git config --global pull.rebase merges
git submodule
- 
Delete the section referring to the submodule from the .gitmodulesfile
- 
Stage the changes via git add .gitmodules
- 
Delete the relevant section of the submodule from .git/config.
- 
Run git rm --cached path_to_submodule(no trailing slash).
- 
Run rm -rf .git/modules/path_to_submodule
- 
Commit the changes with git commit -m "Removed submodule"
- 
Delete the now un-tracked submodule files rm -rf path_to_submodule
git
To search for strings in an entire git repository:
git grep -i '<regex>' $(git rev-list --all)
Refer to https://rtyley.github.io/bfg-repo-cleaner/ for instructions and
the Jar file. Setup an alias for bfg, replacing the Java and Jar paths, as
needed.
Function _bfg {
    $JavaExe = Get-Command "C:\Program Files\OpenJDK\jdk-15\bin\java.exe"
    $JarPath = Resolve-Path ~\Downloads\bfg-1.13.0.jar
    & $JavaExe -jar $JarPath $Args
}
Set-Alias -Name bfg -Value _bfg
Create passwords.txt with the Regex or strings to be replaced with
***REMOVED***.
# Add regex(s) to file.
@('<regex>', '<regex>') -join "`n" |
  Out-File -Encoding utf8 -NoNewline -FilePath passwords.txt
# Replace regex with **REMOVED**
bfg --replace-text passwords.txt vimfiles.git
# If all goes well, clean up the history.
git reflog expire --expire=now --all && git gc --prune=now --aggressive
Clone the mirror repository, remove any secrets from HEAD, commit and push back
to the local mirror repository. Re-run bfg to remove from the history,
assuming everything works. git pull to update the clone. Then change the remote to Github.
Removing Sensitive Data from a Repository
provides instructions for force pushing to Github.
2FA tokens
- 
Git error: remote: Invalid username or password. fatal: Authentication failed- Authentication/Account security/Creating a personal access token
- https://github.com/settings/tokens
- Expired tokens can be refreshed.
- 
Windows Credential Managerstores tokens for Windows 10 and Windows 11.