Failed to push some refs to git что делать
Как исправить ошибку GIT
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
Репозиторий на GitHub был только что создан и там нет никаких изменений
2 ответа 2
У вас есть там изменения, которых нет в локальном репозитории. Вы сделали не пустой репозиторий на Github, а с начальным коммитом. У локального репозитория свой первый коммит и эти коммиты, как вы понимаете, не равны (фактические у вас просто два разных репозитория).
У меня была такая же ошибка, когда я сначала создал локальный репозиторий. Потом перешел на ГитХаб и создал новый репозиторий там. Затем выполнил
А когда попробовал сделать push/pull, получил ту же fatal: unrelated_histories ошибку. И вот как я поправил это:
Всё ещё ищете ответ? Посмотрите другие вопросы с метками git или задайте свой вопрос.
Похожие
Подписаться на ленту
Для подписки на ленту скопируйте и вставьте эту ссылку в вашу программу для чтения RSS.
дизайн сайта / логотип © 2021 Stack Exchange Inc; материалы пользователей предоставляются на условиях лицензии cc by-sa. rev 2021.12.2.40878
Нажимая «Принять все файлы cookie» вы соглашаетесь, что Stack Exchange может хранить файлы cookie на вашем устройстве и раскрывать информацию в соответствии с нашей Политикой в отношении файлов cookie.
в Git ошибка: не удалось подтолкнуть некоторые ссылки на
по какой-то причине, я не могу нажать сейчас, в то время как я мог бы сделать это вчера. Может быть, я перепутал с конфигурациями или что-то в этом роде.
вот что происходит:
когда я использую git push origin master
Как выглядит мой рабочий каталог и удаленный репозиторий:
17 ответов:
если репозиторий GitHub видел новые коммиты, которые были нажаты на него, пока вы работали локально, я бы посоветовал использовать:
посмотреть более полный пример в Глава 6 потяните с rebase на Git Pocket Book.
это установит связь отслеживания между вашей локальной главной ветвью и ее восходящей ветвью.
После этого любой будущий толчок для этой ветви можно сделать с помощью простого:
Это должно решить проблему.
У меня была такая же проблема. Я получал эту проблему, потому что я не сделал никакого коммита, даже начального коммита, и все же я пытался нажать.
Я нахожу решение этой проблемы в справке github.
вы можете исправить это путем извлечения и объединения изменений, внесенных в удаленной ветви с изменениями, которые вы сделали локально:
или вы можете просто использовать git pull для выполнения обеих команд сразу:
Если вы используете gerrit, это может быть вызвано неправильным изменением-id в фиксации. Попробуйте удалить Change-Id и посмотреть, что произойдет.
переименуйте свою ветку, а затем нажмите, например:
это сработало для меня.
Не забудьте зафиксировать свои изменения, прежде чем нажимать на репо Github. Это может решить вашу проблему.
Не фиксация начальных изменений перед нажатием также вызывает проблему
3) git remote-v (для проверки текущего репозитория)
4) git add-A (добавить все файлы)
5) git commit-m ‘Added my project’
7) git push origin master
Ну, если ни один из вышеперечисленных ответов не работает, и если вы что-то перепутали с ssh-add в последнее время. Попробуй
в моем случае эта ошибка произошла из-за того, что в нашей версии GitLab происходило некоторое обслуживание.
вы также можете исправить это, отредактировав файл конфигурации git вашего проекта:
добавьте следующие строки в конце, если это не так.
[branch «master»] remote = origin merge = refs/heads/master
в моем случае закрытие редактора (visual studio code) решило проблему.
ошибка git: не удалось нажать некоторые ссылки также приходит, когда имя локального репозитория совпадает с соответствующим именем удаленного репозитория. Убедитесь, что вы работаете над правильной парой репозиториев, прежде чем извлекать изменения в удаленный репозиторий. Если вы пишете неправильно и хотите удалить локальный репозиторий, выполните следующие действия
I have some projects I would like to upload on my bitbucket private profile. I performed the following steps but I get an error.
Convert my project to git with: git init
I created a bitbucket repository and version control system is GIT.
I then type this (of course with real account name and reponame and repo owner):
I did all of this and my terminal gives me this error:
9 Answers 9
Your master branch has some code that you don’t locally have, and to prevent you from conflicts, it doesn’t let you to push further changes, before you have them locally. To resolve this, pull all the changes to your local repository (your project):
After that, you will have all the code that is available on your master branch.
NOTE: Be careful, pulling the code from remote branch might mess up all the changes locally. Make sure to save those changes somewhere, or create another branch locally where you will pull your origin master branch, so it doesn’t mess up your changes.
Your remote repository and local repository have differences, something new in remote repository. So for pushing you need pull changes, from remote, previously. Try do:
The issue is because your remote repository and local repository have differences.I had same issue and i tried all the above mentioned solution but nothing worked for me. For me the scenario was :- I already had my branch in remote repository.If you have the same scenario then follow below steps:-
run command ‘git pull’
delete branch from local repository
checkout that particular branch using «checkout as a new local branch» from the Remote repository.
Your issue is that you have different things between your local repository and your git repository (probably a readme file that you created automatically), so you have two options:
12 Answers 12
Your origin repository is ahead of your local repository. You’ll need to pull down changes from the origin repository as follows before you can push. This can be executed between your commit and push.
development refers to the branch you want to pull from. If you want to pull from master branch then type this one.
In my case Github was down.
You can subscribe to notifications per email and text to know when you can push your changes again.
I used this command and it worked fine with me:
But notice, that may delete some files you already have on the remote repo. That came in handy with me as the scenario was different; I was pushing my local project to the remote repo which was empty but the READ.ME
I have faced the same issue and resolved as follows (if you have a project in local folder then follow the steps):
you can write in your console:
then press TAB and write your «master» repository
In my case. I had the error because I forgot to make a commit after create a repository on github into an existing project. So I solved:
Then I was able to type:
Sometimes #1 works and sometimes #2 for me. I am not sure why it reacts in this way
Came to find out this is the reason:
In windows, you need to use double quotes «». So the command would be
In my case git push was trying to push more that just the current branch, therefore, I got this error since the other branches were not in sync.
This will only work on more recent versions of git. i.e.: won’t work on 1.7.9.5
This command worked for me:
And if it doesn’t work, please make sure that you are pushing on the current branch that you are on it.
And after that, you must push your code on the master branch
Not the answer you’re looking for? Browse other questions tagged github git-push or ask your own question.
Linked
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.12.2.40878
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
How to fix : failed to push some refs to gitlab?
I tried to push the project to the repository of GitLab but there was an error occurred.
How can I fix this?
Git repository wasn’t created by me, it was created by the client. And he asked me to push the code to the branch which I made by myself and let him know when I finish.
To do this task, I did like following
I expected the successful push result but the above error occurred.
2 Answers 2
How can I fix [an error of the form pre-receive hook declined ]?
[The] Git repository wasn’t created by me, it was created by the client.
In general, you cannot fix this. Only the owner of the repository can do that, because a pre-receive hook is something they control and you don’t.
A pre-receive hook is basically a verifier, a sort of policeman of push requests. He—if we can anthropomorphize this hook—inspects your push request in any way he’s told. Typically, he’d look at each of the commits you propose to add to the repository, but without any information or hint as to what kind of checks this pre-receive hook was told to perform, we—the people reading your question—cannot guess what inspections he might be doing. Nor can you, for that matter: you can only know what he tells you.
So: did he tell you anything? Did he say: «I don’t like your commit because _____»? (fill in the blank) If so, pay attention to that announcement. But if he didn’t tell you anything, well, we can’t either. That’s not your fault: anyone writing a custom GitLab hook of this sort must tell their users why they’re rejecting the commit, otherwise everyone is in the dark.