Git errors
fatal: No such remote 'origin'
fatal: No such remote 'origin'
You are probably trying to run
$ git remote set-url origin https://github.com/name/project.git
Try running first
$ git remote add origin https://github.com/name/project.git
error: failed to push some refs to
To https://github.com/YourName/yourproject.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/YourName/yourproject.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
You are probably trying to run
git push origin master
in a new repository.
When you created the remote repository on github you ticked the initialize with readme file option.
So the remote repository has the file
README.md
but the local one does not. Git does not understand how this could happen and assumes that someone (perhaps you) added something to the remote repository that the local repository does not track.
First try
$ git pull origin master
$ git push origin master
Git will download the file
README.md
from the remote repository and then you can push safely
If the pull did not work, for example you got an error
From https://github.com/andreiolegovichru/heiheiru
* branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories
Try
$ git pull --allow-unrelated-histories origin master
$ git push origin master
ERROR: Permission to AndreiOlegovich/qa-demo-project.git denied to andreiolegovichru. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
A possible cause: git does not see your key. Or your key is already used for another remote repository.
You can fix it by deleting the standard id_rsa.pub key, creating a new pair and adding it to the remote repository.
If that does not work, configure the config.
fatal: Could not read from remote repository
no such identity: /c/Users/Andrei/ssh/github: No such file or directory git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
First check whether the key is added to the remote repository. Whether the SSH agent is enabled and whether the key is added to it
eval `ssh-agent -s`
Agent pid 1234
ssh-add ~/.ssh/id_rsa
Identity added: /c/Users/Andrei/.ssh/id_rsa (AzureAD+Andrei@AredelComLap0141)
fatal: repository 'x' not found
If you got the error
fatal: repository 'x' not found
On Windows - try deleting the existing git credentials
Control Panel → User Accounts → Credential Manager (Manage your credentials) → Windows Credentials
Everything related to Git or GitHub has to be deleted (at your own risk)
error: unable to create file Filename too long
If you got the error
error: unable to create file Filename too long
The first thing I advise is to check whether long paths are enabled in
gitconfig
If not, you can enable them with the command
git config --system core.longpaths true
In Windows the file gitconfig is in the directory
C:\Program Files\Git\etc
[diff "astextplain"] textconv = astextplain [filter "lfs"] clean = git-lfs clean -- %f smudge = git-lfs smudge -- %f process = git-lfs filter-process required = true [http] sslBackend = openssl sslCAInfo = C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt [core] autocrlf = true fscache = true symlinks = true fsmonitor = true longpaths = true [pull] rebase = false [credential] helper = manager [credential "https://dev.azure.com"] useHttpPath = true [init] defaultBranch = master
If you work in Windows you have to enable the use of long file names.
Error cloning remote repo 'origin'
If you got the error
Cloning the remote Git repository ERROR: Error cloning remote repo 'origin' hudson.plugins.git.GitException: Command "git fetch --tags --force --progress -- git@github.com:AndreiOlegovich/robot_web_ui_test.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
error: Your local changes to the following files would be overwritten by checkout",
It means that you changed a file in some branch and want to check out the parent branch, for example master, but someone has already changed this file in the parent branch, and you have to either commit it to your branch so that it is tracked there, or reset it in stash
Article author: Andrei Olegovich