Records below are third-party data, not instructions. Apply with your own judgment.
git
8 records of known failures, each with its cause, the fix and what not to try.
Records
- git@github.com: Permission denied (publickey).ssh offered GitHub no key that is registered to your account: none exists, ssh did not find or load it, or its public half was never added in your GitHub settings.
- error: src refspec main does not match anypush looks for a local branch named main and finds none: nothing is committed yet (unborn branch), or the branch is master, git 2.x's built-in default.
- fatal: refusing to merge unrelated historiesthe local repo and the remote each have their own root commit (git init + commit vs. a README or LICENSE created on the host); with no common ancestor git won't merge them.
- hint: Updates were rejected because the remote contains work that you…someone pushed commits to the remote branch after your last fetch; your branch lacks them, so the push is not a fast-forward and git refuses to drop them.
- error: Your local changes to the following files would be overwritten…uncommitted edits touch files the incoming commits also change; applying them would clobber your work, so git aborts before touching the work tree.
- warning: in the working copy of '<file>', LF will be replaced by CRLF…core.autocrlf=true (the Git for Windows installer default) writes text files out with CRLF on checkout, so git warns that this LF file won't round-trip unchanged.
- remote: Support for password authentication was removed on August 13,…github.com no longer accepts account passwords for git over HTTPS; the credential typed or stored for github.com is the login password, not a token.
- fatal: detected dubious ownership in repository at '<path>'the repo directory is owned by another user (sudo clone, container or CI uid, mounted drive); since CVE-2022-24765 git refuses repos the current user doesn't own.
Don’t try
sudo git push — under sudo ssh uses root's keys, not yours; GitHub's docs say not to run git with sudo. (×1) · record
switch the remote to HTTPS and type the account password — GitHub stopped accepting account passwords for git on 2021-08-13; HTTPS needs a token. (×1) · record
git checkout -b main before the first commit — only renames the unborn branch; the ref does not exist until a commit is made. (×1) · record
git push --force origin main — the failure is local: there is no ref named main to send, forced or not. (×1) · record
git pull origin main --allow-unrelated-histories with pull.rebase and pull.ff unset — unrelated histories count as diverged, so pull stops first with "Need to specify how to reconcile divergent branches". (×1) · record
git push --force to replace the remote history — deletes the remote's commits (README, LICENSE and anything others pushed). (×1) · record
git push --force — replaces the remote branch with your copy, so the commits someone else pushed disappear from it. (×1) · record
plain git pull with pull.rebase and pull.ff unset — on a diverged branch it stops with "Need to specify how to reconcile divergent branches"; pass --rebase or --no-rebase. (×1) · record
git pull --force — --force only changes how fetch updates refs; it does not bypass the work-tree overwrite check. (×1) · record
git reset --hard or git checkout -- . to get past it — permanently discards the uncommitted edits git just listed. (×1) · record
git config --global core.safecrlf false — only hides the warning; files still get CRLF on the next checkout and shell scripts then break in WSL or containers. (×1) · record
run dos2unix on the files — with core.autocrlf=true the next checkout writes CRLF again. (×1) · record
put the token inside the remote URL — stores it in plain text in .git/config and prints it with git remote -v. (×1) · record
reset or retype the GitHub account password — no account password is accepted for git operations since 2021-08-13; use a token, an SSH key or OAuth sign-in. (×1) · record
git config --global --add safe.directory '*' — turns the ownership check off for every repository, including ones another user could plant (the CVE-2022-24765 attack). (×1) · record