I just started using git with github. I followed their instructions and ran into errors on the last step. I’m checking in an existing directory that isn’t currently source-controlled (project about a week old). Other than that, my use case should be pretty run of the mill.
Here’s what’s happening:
$ git push origin master
error: src refspec master does not match any.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'git@github.com:{username}/{projectname}.git'
Github’s instructions:
Global setup:
Download and install Git
git config --global user.name "Your Name"
git config --global user.email {username}@gmail.com
Next steps:
mkdir projectname
cd projectname
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@github.com:{username}/{projectname}.git
git push origin master
Ikke
99.5k23 gold badges97 silver badges120 bronze badges
asked May 5, 2009 at 23:13
7
I was having the same issue and then smacked myself in the head because I hadn’t actually added my project files.
git add -A
git commit -am "message"
git push origin master
Till
22.2k4 gold badges59 silver badges89 bronze badges
answered Nov 14, 2009 at 2:17
Joey GreenJoey Green
3,0603 gold badges19 silver badges14 bronze badges
2
The error message leads to the conclusion that you do not have a master
branch in your local repository. Either push your main development branch (git push origin my-local-master:master
which will rename it to master
on github) or make a commit first. You can not push a completely empty repository.
answered May 6, 2009 at 6:32
BombeBombe
81.8k20 gold badges123 silver badges127 bronze badges
3
I had the same issue. I deleted the .git folder then followed the following commands
$ git init
$ git add .
$ git remote add origin git@gitorious.org:project/project.git
$ git commit -m "Initial version"
$ git push origin master
Dan McClain
11.8k9 gold badges47 silver badges67 bronze badges
answered Jun 29, 2011 at 9:55
I have same issue . it’s solved my problem .
İf you init your git . you have to do on Terminal
1) git add .
2)git commit -m "first commit"
For send to bitbucket
3) git push -u origin --all # pushes up the repo and its refs for the first time
answered Nov 22, 2013 at 12:01
Erhan DemirciErhan Demirci
4,1694 gold badges36 silver badges44 bronze badges
0
I just had the same problem while creating my first Git repository ever. I had a typo in the Git origin remote creation — turns out I didn’t capitalize the name of my repository.
git remote add origin git@github.com:Odd-engine
First I removed the old remote using
git remote rm origin
Then I recreated the origin, making sure the name of my origin was typed EXACTLY the same way my origin was spelled.
git remote add origin git@github.com:Odd-Engine
No more error!
answered Apr 9, 2012 at 22:21
I had the same error, as Bombe said I had no local branch named master in my config, although git branch
did list a branch named master…
To fix it just add this to your .git/config
[branch "master"]
remote = origin
merge = refs/heads/master
Kinda hacky but does the job
answered Aug 13, 2009 at 12:59
make sure you are on a branch, at least in master branch
type:
git branch
you should see:
ubuntu-user:~/git/turmeric-releng$ git branch
* (no branch)
master
then type:
git checkout master
then all your changes will fit in master branch (or the branch u choose)
answered Sep 9, 2011 at 18:22
error: failed to push some refs to 'git@github.com:{username}/{projectname}.git'
Unless you’re generalizing the error message, it looks like you literally put git@github.com:{username}/{projectname}.git
as your remote Git repo. You should fill in {username}
with your GitHub username, and {projectname}
with your project’s name.
answered Sep 15, 2009 at 22:01
mipadimipadi
399k90 gold badges523 silver badges479 bronze badges
To actually resolve the issue I used the following command to stage all my files to the commit.
$ git add .
$ git commit -m 'Your message here'
$ git push origin master
The problem I had was that the -u command in git add didn’t actually add the new files and the git add -A command wasn’t supported on my installation of git. Thus as mentioned in this thread the commit I was trying to stage was empty.
answered Jan 29, 2011 at 21:45
AsciantAsciant
2,1301 gold badge15 silver badges26 bronze badges
1
It looks like this question has a number of answers already, but I’ll weigh in with mine since I haven’t seen any that address the issue I had.
I had this error as well on a brand new github repository. It turns out the user I was pushing from did not have push access. For some reason, this results in an «ERROR: repository not found» error instead of some sort of access error.
Anyway, I hope this helps the poor soul who runs into the same issue.
answered Apr 23, 2012 at 22:20
TomTom
18.7k15 gold badges71 silver badges81 bronze badges
i fixed my problem….
not sure what the problem was but using the gitx interface to commit my staged files, then…
$ git push origin master
worked…
i am having the same problem…
created a new folder added in the bort template files…
$ git commit -m 'first commit'
$ git remote add origin git@github.com:eltonstewart/band-of-strangers.git
$ git push origin master
then i get the same error…
error: src refspec master does not match any.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to ‘git@github.com:eltonstewart/band-of-strangers.git’
Arnis Lapsa
46k29 gold badges115 silver badges195 bronze badges
answered May 16, 2009 at 5:49
cd app
git init
git status
touch test
git add .
git commit -a -m"message to log "
git commit -a -m "message to log"
git remote add origin
git remote add origin git@git.google.net:cherry
git push origin master:refs/heads/master
git clone git@git.google.net:cherry test1
answered Apr 25, 2011 at 6:34
I had same issue. I had mistakenly created directory in machine in lower case. Once changed the case , the problem solved(but wasted my 1.5 hrs )
Check it out your directory name and remote repo name is same.
answered Feb 4, 2012 at 17:59
had the same issue a minute ago and then fixed it
create a repository in github called wordpress…
cd wordpress
git init
git add -A
git commit -am “WordPress 3.1.3″ or any message
git remote add origin git@github.com:{username}/wordpress.git
git push -u origin master
this should work to resolve the refspec issue
Riduidel
22.1k14 gold badges86 silver badges185 bronze badges
answered May 26, 2011 at 20:07
David ChaseDavid Chase
2,0551 gold badge18 silver badges25 bronze badges
2
This can also happen because github has recently renamed the default branch from «master» to «main» ( https://github.com/github/renaming ), so if you just created a new repository on github use git push origin main
instead of git push origin master
answered Dec 18, 2020 at 1:05
mechatronermechatroner
1,2721 gold badge17 silver badges25 bronze badges
I mistankly put a space after the — so instead of -m I had — m
Just something to look for.
answered Mar 6, 2010 at 23:20
I think in older version of git, you should commit at least one file first, and then you can «push origin master» once again.
answered Mar 7, 2010 at 10:33
great.. its the issue with empty directory only nothing else. I got my issue resolved by creating one binary file in each directory and then added them.
answered Mar 13, 2010 at 21:20
Initital add & commit worked like a charm. I guess it’s just a matter of understanding Git’s methodology of managing a project within the repository.
After that I’ve managed to push my data straight-away with no hassle.
answered Mar 28, 2011 at 16:28
Matthew MorekMatthew Morek
2,8262 gold badges17 silver badges13 bronze badges
I just encountered this problem, and it seemed to be caused by my not adding a custom commit message above the default commit message (I figured, why write «initial commit», when it clearly says that very same thing in the Git-generated text below it).
The problem resolved when I removed the .git directory, re-initialized the project directory for Git, re-added the GitHub remote, added all files to the new stage, committed with a personal message above the auto-generated message, and pushed to origin/master.
answered Jun 13, 2014 at 23:46
25406252540625
11.1k8 gold badges52 silver badges58 bronze badges
When you create a repository on Github, It adds a README.md file to the repo and since this file might not be there in your local directory, or perhaps it might have different content git push would fail.
To solve the problem I did:
git pull origin master
git push origin master
This time it worked since I had the README.md file.
answered Sep 6, 2014 at 22:30
Sahil SinghSahil Singh
3,35240 silver badges62 bronze badges
Before the first commit, try add some file like readme.txt. This will «force» the remote repo create the branch master in case that not exists. It’s worked to me.
answered Oct 10, 2014 at 16:35
This is very old question but for all new people who will end up here like me.
This solution is only for
error: src refspec master does not match any.
error for new repo created
You need to add your
git config user.email "your email"
git config user.name "name"
Only after adding email and name add files to git and commit
git add .
git commit -m "message"
It will work like charm
answered Feb 16, 2015 at 13:03
PankajPankaj
1,2421 gold badge9 silver badges21 bronze badges
I have this error too, i put a commit for not push empty project like a lot of people do but doesn’t work
The problem was the ssl, y put the next
git config —system http.sslverify false
And after that everything works fine
git push origin master
answered Feb 16, 2016 at 4:48
I was having same problem/error.I was doing git push -u origin master
instead i just did git push origin master
and it worked.
answered Sep 12, 2016 at 10:54
Ali AkramAli Akram
1994 silver badges12 bronze badges
go to control panel -> manage your credentials and delete github credentials if any.
answered Sep 15, 2019 at 17:38
Bumping an old thread.
If you have created a repository on Github with a Readme
or a .gitignore
, you might have to rebase the local master with the remote master. Because, if you are using a project scaffolding tool, like create-app, it creates these files for you, and the remote master needs to be synced with your local before you push.
If you are creating an empty repository on Github, then you can simply push.
answered Jul 7, 2020 at 20:29
Rutwick GangurdeRutwick Gangurde
4,77211 gold badges53 silver badges87 bronze badges
As some commented above, the problem could be that you do not have email and username or also in my case the problem was that I was trying to push the branch with a different email in the configuration, to check this:
git config --list
to modify it (globally):
git config --global user.email "email@email.com"
answered Apr 24, 2022 at 20:06
AlezDsGsAlezDsGs
111 silver badge3 bronze badges
I had the same problem, some of the users have answered this. Before push you must have your first commit.
Now for new users I’ve created a series of simple steps. Before that you need to install git and run in command line:
- git config user.email «your email»
- git config user.name «name»
The steps for creating a remote repository (I use dropbox as remote repository):
1. create a directory in Dropbox (or on your remote server)
2. go to the Dropbox dir (remote server dir)
3. type git command: git init --bare
4. on your local drive create your local directory
5. go to local directory
6. type git command: git init
7. add initial files, by typing git command:: git add <filename>
8. type git command: git commit -a -m "initial version" (if you don't commit you can't do the initial push
9. type git command: git remote add name <path to Dropbox/remote server>
10. git push name brach (for first commit the branch should be master)
answered Feb 24, 2015 at 8:53
I just started using git with github. I followed their instructions and ran into errors on the last step. I’m checking in an existing directory that isn’t currently source-controlled (project about a week old). Other than that, my use case should be pretty run of the mill.
Here’s what’s happening:
$ git push origin master
error: src refspec master does not match any.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'git@github.com:{username}/{projectname}.git'
Github’s instructions:
Global setup:
Download and install Git
git config --global user.name "Your Name"
git config --global user.email {username}@gmail.com
Next steps:
mkdir projectname
cd projectname
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@github.com:{username}/{projectname}.git
git push origin master
Ikke
99.5k23 gold badges97 silver badges120 bronze badges
asked May 5, 2009 at 23:13
7
I was having the same issue and then smacked myself in the head because I hadn’t actually added my project files.
git add -A
git commit -am "message"
git push origin master
Till
22.2k4 gold badges59 silver badges89 bronze badges
answered Nov 14, 2009 at 2:17
Joey GreenJoey Green
3,0603 gold badges19 silver badges14 bronze badges
2
The error message leads to the conclusion that you do not have a master
branch in your local repository. Either push your main development branch (git push origin my-local-master:master
which will rename it to master
on github) or make a commit first. You can not push a completely empty repository.
answered May 6, 2009 at 6:32
BombeBombe
81.8k20 gold badges123 silver badges127 bronze badges
3
I had the same issue. I deleted the .git folder then followed the following commands
$ git init
$ git add .
$ git remote add origin git@gitorious.org:project/project.git
$ git commit -m "Initial version"
$ git push origin master
Dan McClain
11.8k9 gold badges47 silver badges67 bronze badges
answered Jun 29, 2011 at 9:55
I have same issue . it’s solved my problem .
İf you init your git . you have to do on Terminal
1) git add .
2)git commit -m "first commit"
For send to bitbucket
3) git push -u origin --all # pushes up the repo and its refs for the first time
answered Nov 22, 2013 at 12:01
Erhan DemirciErhan Demirci
4,1694 gold badges36 silver badges44 bronze badges
0
I just had the same problem while creating my first Git repository ever. I had a typo in the Git origin remote creation — turns out I didn’t capitalize the name of my repository.
git remote add origin git@github.com:Odd-engine
First I removed the old remote using
git remote rm origin
Then I recreated the origin, making sure the name of my origin was typed EXACTLY the same way my origin was spelled.
git remote add origin git@github.com:Odd-Engine
No more error!
answered Apr 9, 2012 at 22:21
I had the same error, as Bombe said I had no local branch named master in my config, although git branch
did list a branch named master…
To fix it just add this to your .git/config
[branch "master"]
remote = origin
merge = refs/heads/master
Kinda hacky but does the job
answered Aug 13, 2009 at 12:59
make sure you are on a branch, at least in master branch
type:
git branch
you should see:
ubuntu-user:~/git/turmeric-releng$ git branch
* (no branch)
master
then type:
git checkout master
then all your changes will fit in master branch (or the branch u choose)
answered Sep 9, 2011 at 18:22
error: failed to push some refs to 'git@github.com:{username}/{projectname}.git'
Unless you’re generalizing the error message, it looks like you literally put git@github.com:{username}/{projectname}.git
as your remote Git repo. You should fill in {username}
with your GitHub username, and {projectname}
with your project’s name.
answered Sep 15, 2009 at 22:01
mipadimipadi
399k90 gold badges523 silver badges479 bronze badges
To actually resolve the issue I used the following command to stage all my files to the commit.
$ git add .
$ git commit -m 'Your message here'
$ git push origin master
The problem I had was that the -u command in git add didn’t actually add the new files and the git add -A command wasn’t supported on my installation of git. Thus as mentioned in this thread the commit I was trying to stage was empty.
answered Jan 29, 2011 at 21:45
AsciantAsciant
2,1301 gold badge15 silver badges26 bronze badges
1
It looks like this question has a number of answers already, but I’ll weigh in with mine since I haven’t seen any that address the issue I had.
I had this error as well on a brand new github repository. It turns out the user I was pushing from did not have push access. For some reason, this results in an «ERROR: repository not found» error instead of some sort of access error.
Anyway, I hope this helps the poor soul who runs into the same issue.
answered Apr 23, 2012 at 22:20
TomTom
18.7k15 gold badges71 silver badges81 bronze badges
i fixed my problem….
not sure what the problem was but using the gitx interface to commit my staged files, then…
$ git push origin master
worked…
i am having the same problem…
created a new folder added in the bort template files…
$ git commit -m 'first commit'
$ git remote add origin git@github.com:eltonstewart/band-of-strangers.git
$ git push origin master
then i get the same error…
error: src refspec master does not match any.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to ‘git@github.com:eltonstewart/band-of-strangers.git’
Arnis Lapsa
46k29 gold badges115 silver badges195 bronze badges
answered May 16, 2009 at 5:49
cd app
git init
git status
touch test
git add .
git commit -a -m"message to log "
git commit -a -m "message to log"
git remote add origin
git remote add origin git@git.google.net:cherry
git push origin master:refs/heads/master
git clone git@git.google.net:cherry test1
answered Apr 25, 2011 at 6:34
I had same issue. I had mistakenly created directory in machine in lower case. Once changed the case , the problem solved(but wasted my 1.5 hrs )
Check it out your directory name and remote repo name is same.
answered Feb 4, 2012 at 17:59
had the same issue a minute ago and then fixed it
create a repository in github called wordpress…
cd wordpress
git init
git add -A
git commit -am “WordPress 3.1.3″ or any message
git remote add origin git@github.com:{username}/wordpress.git
git push -u origin master
this should work to resolve the refspec issue
Riduidel
22.1k14 gold badges86 silver badges185 bronze badges
answered May 26, 2011 at 20:07
David ChaseDavid Chase
2,0551 gold badge18 silver badges25 bronze badges
2
This can also happen because github has recently renamed the default branch from «master» to «main» ( https://github.com/github/renaming ), so if you just created a new repository on github use git push origin main
instead of git push origin master
answered Dec 18, 2020 at 1:05
mechatronermechatroner
1,2721 gold badge17 silver badges25 bronze badges
I mistankly put a space after the — so instead of -m I had — m
Just something to look for.
answered Mar 6, 2010 at 23:20
I think in older version of git, you should commit at least one file first, and then you can «push origin master» once again.
answered Mar 7, 2010 at 10:33
great.. its the issue with empty directory only nothing else. I got my issue resolved by creating one binary file in each directory and then added them.
answered Mar 13, 2010 at 21:20
Initital add & commit worked like a charm. I guess it’s just a matter of understanding Git’s methodology of managing a project within the repository.
After that I’ve managed to push my data straight-away with no hassle.
answered Mar 28, 2011 at 16:28
Matthew MorekMatthew Morek
2,8262 gold badges17 silver badges13 bronze badges
I just encountered this problem, and it seemed to be caused by my not adding a custom commit message above the default commit message (I figured, why write «initial commit», when it clearly says that very same thing in the Git-generated text below it).
The problem resolved when I removed the .git directory, re-initialized the project directory for Git, re-added the GitHub remote, added all files to the new stage, committed with a personal message above the auto-generated message, and pushed to origin/master.
answered Jun 13, 2014 at 23:46
25406252540625
11.1k8 gold badges52 silver badges58 bronze badges
When you create a repository on Github, It adds a README.md file to the repo and since this file might not be there in your local directory, or perhaps it might have different content git push would fail.
To solve the problem I did:
git pull origin master
git push origin master
This time it worked since I had the README.md file.
answered Sep 6, 2014 at 22:30
Sahil SinghSahil Singh
3,35240 silver badges62 bronze badges
Before the first commit, try add some file like readme.txt. This will «force» the remote repo create the branch master in case that not exists. It’s worked to me.
answered Oct 10, 2014 at 16:35
This is very old question but for all new people who will end up here like me.
This solution is only for
error: src refspec master does not match any.
error for new repo created
You need to add your
git config user.email "your email"
git config user.name "name"
Only after adding email and name add files to git and commit
git add .
git commit -m "message"
It will work like charm
answered Feb 16, 2015 at 13:03
PankajPankaj
1,2421 gold badge9 silver badges21 bronze badges
I have this error too, i put a commit for not push empty project like a lot of people do but doesn’t work
The problem was the ssl, y put the next
git config —system http.sslverify false
And after that everything works fine
git push origin master
answered Feb 16, 2016 at 4:48
I was having same problem/error.I was doing git push -u origin master
instead i just did git push origin master
and it worked.
answered Sep 12, 2016 at 10:54
Ali AkramAli Akram
1994 silver badges12 bronze badges
go to control panel -> manage your credentials and delete github credentials if any.
answered Sep 15, 2019 at 17:38
Bumping an old thread.
If you have created a repository on Github with a Readme
or a .gitignore
, you might have to rebase the local master with the remote master. Because, if you are using a project scaffolding tool, like create-app, it creates these files for you, and the remote master needs to be synced with your local before you push.
If you are creating an empty repository on Github, then you can simply push.
answered Jul 7, 2020 at 20:29
Rutwick GangurdeRutwick Gangurde
4,77211 gold badges53 silver badges87 bronze badges
As some commented above, the problem could be that you do not have email and username or also in my case the problem was that I was trying to push the branch with a different email in the configuration, to check this:
git config --list
to modify it (globally):
git config --global user.email "email@email.com"
answered Apr 24, 2022 at 20:06
AlezDsGsAlezDsGs
111 silver badge3 bronze badges
I had the same problem, some of the users have answered this. Before push you must have your first commit.
Now for new users I’ve created a series of simple steps. Before that you need to install git and run in command line:
- git config user.email «your email»
- git config user.name «name»
The steps for creating a remote repository (I use dropbox as remote repository):
1. create a directory in Dropbox (or on your remote server)
2. go to the Dropbox dir (remote server dir)
3. type git command: git init --bare
4. on your local drive create your local directory
5. go to local directory
6. type git command: git init
7. add initial files, by typing git command:: git add <filename>
8. type git command: git commit -a -m "initial version" (if you don't commit you can't do the initial push
9. type git command: git remote add name <path to Dropbox/remote server>
10. git push name brach (for first commit the branch should be master)
answered Feb 24, 2015 at 8:53
I modify my local file. I commit locally and it’s ok. But when i push to github, i have the message that all things are update. Here is the command and its result :
git push origin master
I have the following error message :
Everything up-to-date
Then to see what happen, i run gitK command and i have :
I don’t understand why i am getting this error ? Why i cannot push my code to github ?
I run the command :
git status
On branch dev-branch
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: deploy/openshift (modified content)
no changes added to commit (use "git add" and/or "git commit -a")
asked Jun 9, 2015 at 22:00
PracedePracede
4,22616 gold badges65 silver badges110 bronze badges
7
According to your git status
message, you are on branch dev-branch
not master
.
When you git push origin master
the last parameter is the branch name. You have commits in a branch named dev-branch
not in master
, so pushing master
does not have any changes to push.
You probably either want to:
git push origin dev-branch
which would create the dev-branch
branch on GitHub and push your code there, or..
git checkout master
git merge dev-branch
git push origin master
which would merge your changes from dev-master
into master
(so master would contain all your commits from dev-branch) then push master to GitHub.
answered Jun 23, 2015 at 1:08
CodingWithSpikeCodingWithSpike
42.9k18 gold badges101 silver badges138 bronze badges
You are getting this message beacause you have unstaged changes.
In order to push changes to the server you must follow these steps:
-
Stage changes : This is when you tell git to track a certain file for changes. You can do this from the command line with :
git add -u <filename>
(the-u
flag only adds files that have been updated, thanks to o11c for the tip!) -
Commit changes : Once you have added all the files to the stage you need to save them locally with
git commit -m "A commit message here"
-
Push to server : Now run
git push origin master
Do everything in one step:
# This adds all updated files in current folder to the stage,
# then commits with message and pushes to server
$ git add -u .; git commit -m "[YOUR MESSAGE HERE]"; git push origin master
answered Jun 9, 2015 at 22:05
Jose LlausasJose Llausas
3,3761 gold badge20 silver badges24 bronze badges
4
fatal: No such remote ‘origin’ | |
error: failed to push some refs to | |
fatal: Could not read from remote repository | |
Другие статьи про Git |
fatal: No such remote ‘origin’
fatal: No such remote ‘origin’
Скорее всего Вы пытаетесь выполнить
$ git remote set-url origin https://github.com/name/project.git
Попробуйте сперва выполнить
$ 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.
Скорее всего Вы пытаетесь выполнить
git push origin master
в новом репозитории.
При этом, когда
Вы создавали удалённый репозиторий на github Вы отметили опцию initialize with readme file.
Таким образом на удалённом репозитории файл
README.md
есть, а на локальном нет. Git не
понимает как такое могло произойти и предполагает, что на удалённый репозиторий кто-то (возможно Вы)
добавил что-то неотслеженное локальным репозиторием.
Первым делом попробуйте
$ git pull origin master
$ git push origin master
Git скачает файл
README.md
с удалённого репозитория и затем можно будет спокойно пушить
Если сделать pull не получилось, например, возникла ошибка
From https://github.com/andreiolegovichru/heiheiru
* branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories
Попробуйте
$ 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.
Возможная причина — git не видит ваш ключ. Либо ваш ключ уже используется для другого удалённого
хранилища.
Решить можно удалив стандарный ключ id_rsa.pub создать новую пару и добавить на удалённое хранилище.
Если этот способ не подходит — нужно настроить 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.
Первым делом нужно проверить — добавлен ли ключ на удалённый репозиторий. Включен ли
SSH агент и добавлен ли в него этот ключ
eval `ssh-agent -s`
Agent pid 1234
ssh-add ~/.ssh/id_rsa
Identity added: /c/Users/Andrei/.ssh/id_rsa (AzureAD+Andrei@AredelComLap0141)
Git | |
.gitignore | |
Необходимые Bash команды | |
Remote | |
GitHub | |
GitLab | |
Ошибки | |
Git Bash | |
DevOps |
Я клонирую свой репозиторий с помощью:
git clone ssh://xxxxx/xx.git
Но после того, как я изменю некоторые файлы, add
и commit
их, я хочу отправить их на сервер:
git add xxx.php
git commit -m "TEST"
git push origin master
Но ошибка, которую я получаю обратно:
error: src refspec master does not match any.
error: failed to push some refs to 'ssh://xxxxx.com/project.git'
Ответ 1
Возможно, вам просто нужно зафиксировать. Я столкнулся с этим, когда сделал:
mkdir repo && cd repo
git remote add origin /path/to/origin.git
git add .
Oops! Никогда не совершал!
git push -u origin master
error: src refspec master does not match any.
Все, что мне нужно было сделать:
git commit -m "initial commit"
git push origin master
Успех!
Ответ 2
-
Попробуйте
git show-ref
посмотреть, что у вас есть. Есть лиrefs/heads/master
? -
Вы можете попробовать
git push origin HEAD:master
как более локально-независимое решение. Это явно указано, что вы хотите, чтобы подтолкнуть локальный рефHEAD
к удаленному рефуmaster
(см refspec ГИТА-нажимной документация).
Ответ 3
У меня также была аналогичная ошибка после удаления всех файлов на моем локальном компьютере, и я должен очистить все файлы в репозитории.
Мое сообщение об ошибке было примерно таким:
error: src refspec master does not match any.
error: failed to push some refs to '[email protected] ... .git'
и он решил выполнить следующие команды:
touch README
git add README
git add (all other files)
git commit -m 'reinitialized files'
git push origin master --force # <- caution, --force can delete others work.
Это, надеюсь, это поможет.
Ответ 4
- Мои изменения уже были совершены
- Force push все равно дал мне ту же ошибку.
Итак, я попробовал Vi-решение:
git push origin HEAD:<remoteBranch>
Это сработало для меня.
Ответ 5
git push -u origin master
error: src refspec master does not match any.
Для этого вам нужно ввести сообщение коммита следующим образом, а затем нажать код
git commit -m "initial commit"
git push origin master
Успешно толкнул мастера
Ответ 6
Для меня я должен был убедиться, что открытый ключ правильно настроен на сервере (добавлен в ~/.ssh/authorized_keys) и в github/bitbucket (добавлен в мои SSH-ключи на github или битбакет) — они должны соответствовать.
Тогда:
git add --all :/
git commit -am 'message'
git push -u origin master
Работал для меня в конце.
Ответ 7
Я обнаружил, что это произошло в новом репозитории после того, как я git добавил только каталог.
Как только я добавил файл (например, README), git push работал отлично.
Ответ 8
Отсутствие или пропуск git add .
или git commit
может привести к этой ошибке:
git push -u origin master
Username for 'https://github.com': yourusername
Password for 'https://[email protected]':
error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/yourusername/foobar.git'
Чтобы исправить это, повторите инициализацию и следуйте правильной последовательности:
git init
git add .
git commit -m 'message'
git *create remote
git push -u origin master
Ответ 9
Чтобы исправить это, повторите инициализацию и следуйте правильной последовательности кода:
git init
git add .
git commit -m 'message'
git push -u origin master
Ответ 10
Убедитесь, что вы добавили сначала, а затем commit/push:
Подобно:
git init
git add .
git commit -m "message"
git remote add origin "github.com/your_repo.git"
git push -u origin master
Ответ 11
Это происходит также, когда вы находитесь в определенной ветке и пытаетесь нажать другую ветвь, которая еще не существует, например:
$ git branch
* version-x # you are in this branch
version-y
$ git push -u origin master
error: src refspec master does not match any.
error: failed to push some refs to 'origin_address'
Ответ 12
просто добавьте начальную фиксацию, выполните следующие действия: —
-
git add.
-
git commit -m «initial commit»
-
git push origin master
Это сработало для меня
Ответ 13
В моем случае я забыл включить файл .gitignore
. Вот все необходимые шаги:
- Создайте пустой репозиторий Git на удаленном компьютере,
- На локальном создании .gitignore
файл для вашего проекта. Github дает вам список примеров здесь -
Запустите терминал, и в вашем проекте выполните следующие команды:
git remote add origin YOUR/ORIGIN.git
git add .
git commit -m "initial commit or whatever message for first commit"
git push -u origin master
Ответ 14
Я столкнулся с такой же проблемой, и я использовал --allow-empty
.
$ git commit -m "initial commit" --allow-empty
...
$ git push
...
Ответ 15
Вы, вероятно, забыли команду «git add». после команды «git init».
Ответ 16
Моя проблема заключалась в том, что ветвь «master» еще не была создана локально.
Быстрый
git checkout -b "master"
создал главную ветвь, в этот момент быстро:
git push -u origin master
Передвинул работу до репозитория git.
Ответ 17
Я также следовал указаниям githubs, как указано ниже, но все еще сталкивался с той же ошибкой, что и OP:
git init git add. git commit -m "message" git remote add origin "github.com/your_repo.git" git push -u origin master
Для меня, и я надеюсь, что это поможет некоторым, я загружал большой файл (1.58 GB on disk)
на моем MacOS. Копируя, вставляя предложенную строку кодов выше, я не ждал, пока мой процессор завершит add.
процесс. Поэтому, когда я набрал git commit -m "message"
он, по сути, не ссылался ни на какие файлы и не выполнил все, что нужно для успешной фиксации моего кода на github.
Доказательством этого является то, что когда я набираю git status
я обычно получаю зеленые шрифты для добавленных файлов. Но все было красным. Как будто это не было добавлено вообще.
Поэтому я переделал шаги. Набрал git add.
и дождитесь окончания добавления файлов. Затем выполните следующие шаги.
Я надеюсь, что это помогает кому-то.
Ответ 18
Это просто означает, что вы забыли сделать первоначальную фиксацию, попробуйте
git add .
git commit -m 'initial commit'
git push origin master
Ответ 19
- сначала git добавить.
- second git commit -m «message»
- третья git push origin branch
проверьте наличие орфографических ошибок, поскольку это также может привести к этой ошибке.
Ответ 20
У меня была такая же проблема, когда я пропустил запуск:
git add .
(У вас должен быть хотя бы один файл, или вы снова получите ошибку)
Ответ 21
В сценарии, где вы извлекаете код из внешнего репозитория (GitHub),
и хотите импортировать его в личную/внутреннюю систему,
эта команда действительно светит:
git push --all origin
Это подталкивает все локальные ветки к удаленному,
без проверки ссылок, не настаивая на коммитах.
Ответ 22
Это происходит, когда вы добавили свой файл, забыли совершить и нажать.
Поэтому скопируйте файлы, а затем нажмите.
Ответ 23
У меня такая же проблема. Я делаю это, выполнив следующие шаги:
1. git commit -m 'message'
2. git config --global user.email "your mail"
3. git config --global user.name "name"
4. git commit -m 'message'
5. git push -u origin master
Надеюсь, что это поможет кому-то
Ответ 24
Если вы получите эту ошибку при работе в режиме отсоединения HEAD, вы можете сделать это:
git push origin HEAD:remote-branch-name
См. Также: создание git-нажатия от отдельной головки
Если вы находитесь в другом локальном филиале, чем удаленная ветвь, вы можете сделать это:
git push origin local-branch-name:remote-branch-name
Ответ 25
git добавить.
— это все, что вам нужно, чтобы этот трек отслеживал все необработанные файлы в вашем каталоге
Ответ 26
Это также произойдет, если у вас есть опечатка в названии ветки, которую вы пытаетесь нажать.
Ответ 27
Если вы столкнулись с этой проблемой даже после выполнения git init и нажатия начального коммита. Вы можете попробовать следующее,
git checkout -b "new branch name"
git push origin "new branch name"
Ваш код будет нажат как новая ветка.
Ответ 28
Вам нужно настроить свой git, если вы впервые используете его с помощью:
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
Ответ 29
Я забыл сделать «git pull origin master» после фиксации и перед нажатием, и это вызовет ту же проблему: «src refspec master не соответствует никому при нажатии на фиксацию в git».
Итак, что вам нужно сделать:
1. git add .
2. git pull origin master
3. git commit -am "Init commit"
4. git push origin master
Ответ 30
Чтобы проверить текущий статус git status
и выполните следующие действия
git init
git add .
git commit -m "message"
git remote add origin "github.com/your_repo.git"
git push -u origin master