Remote error refusing to update checked out branch refs heads master

Git: выделяем глобальный репозитарий для проекта

Записная книжка рассеянного [в пространстве и времени] программиста

Git: выделяем глобальный репозитарий для проекта

Иногда мы копируем папку с проектом на отдельную машину, а затем пытаемся использовать его в качестве мастер-репозитария.
Но при попытке сделать пуш в этот репозитарий нас подстерегает ошибка.«` $ git push origin master
Counting objects: 30, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (17/17), 3.31 KiB | 0 bytes/s, done.
Total 17 (delta 4), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require ‘git reset –hard’ to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set ‘receive.denyCurrentBranch’ configuration variable to
remote: error: ‘ignore’ or ‘warn’ in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: ‘receive.denyCurrentBranch’ configuration variable to ‘refuse’.
To /project/path
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to ‘/project/path’

Если нет — смотрим выше.

А еще можно сказать иниту, чтобы создавал bare сразу.

Источник

Git Push error: refusing to update checked out branch (Source Control)

August 4, 2014

Recently, I cloned a repository on my machine and made some changes to it. As I was pushing my changes back to the original repo, push failed with the error message:

“refusing to update checked out branch: refs/heads/master. By default, updating the current branch in a non-bare repository is denied…”

There are two things to note here in the error message. First the original repo is non-bare, secondly the push is to a branch which is currently checked out. Following are two possible ways to overcome the issue relating to bare repos and currently checked out branch.

Читайте также:  Dl 420 чип прошивка

Set Repository as ‘Bare’

Bare repositories do not have any working copy. Changes are not done directly to these repositories, rather changes are pushed from clones. Repositories hosted at GitHub are of this type.

One way to resolve the above issue is to make the repository ‘bare’. This can be done by running below command in original repo folder:

Change the checked out branch

If you don’t want to convert your original repository to bare, another option is change the current branch. This can be done by:

In case, there is only one branch in the repository, a temporary branch could be created and checked out:

Once the push is executed, run the following commands to bring things back to original state:

Above will delete the temporary branch and checkout the master branch.

Источник

refusing to update checked out branch: refs/heads/master error #20

Comments

It seems that now edeliver does not handle well cases when SSH connection was dropped.

I’ve tried to run my build twice:

/.profile cd /app/myapp/build &> /dev/null if [ «mix» = «rebar» ]; then echo «using rebar to generate release» &> /dev/null ./rebar -f generate &> /dev/null elif [ «mix» = «relx» ]; then echo «using relx to generate release» &> /dev/null ./relx release &> /dev/null elif [ «mix» = «mix» ]; then echo «using mix to generate release» &> /dev/null MIX_ENV=prod mix release &> /dev/null fi &> /dev/null vagrant@trusty64:/vagrant$ mix edeliver build release BUILDING RELEASE OF PLUMBER APP ON BUILD HOST ——> Authorizing hosts ——> Ensuring hosts are ready to accept git pushes ——> Pushing new commits with git to: app@edeliver.stag.srv.myapp.org ——> Resetting remote hosts to 97f757b0fee0f7ac7602152472cf11bc301bc346 ——> Stashing build directory on remote build host FAILED 1: ssh -o ConnectTimeout=3 app@edeliver.stag.srv.myapp.org set -e [ -f

/.profile cd /app/myapp/build &> /dev/null [[ $(git stash list | wc -l) -gt 0 ]] && _oldest_stash=$(git stash list | tail -1 | grep -o ‘stash@<[0-9]\+>‘ | grep -o ‘[0-9]\+’) || _oldest_stash=0 [[ $ <_oldest_stash>-gt 50 ]] && git stash drop stash@ <$_oldest_stash>&> /dev/null git stash —all &> /dev/null &> /dev/null»>

And then, for the next time I got the following error:

Removing and cloning the repo again on the target machine resolves the issue. It would be nice if edeliver cleaned up repo by itself in case of trouble.

I must admit that the generally speaking, requirement to have valid, cloned git repo on the target machine is a trouble-maker.

First of all, while provisioning build servers you must clone the repo, which forces you to use different authentication scheme to clone it from git than one that is used by the developers on a daily basis.

Than you must ensure that it is valid to avoid problems mentioned before.

Wouldn’t it be just easier to always clone fresh repo before building starts and use SSH key forwarding to ensure that developer’s credentials are used?

The text was updated successfully, but these errors were encountered:

Источник

GIT — Errors

git pull fails : fatal: ‘ /path/to/some/dir ‘ does not appear to be a git repository

Situation

Details

    you have either explicitly typed it or configured Git so that it receives a command such as :

Читайте также:  Internal server error rewriterule

Solution

Several reasons may cause this error :

  • the URL you’re trying to connect to actually is not available :
    • for an https://. URL or a git@. SSH URL :
      • network / connectivity issue
      • server down
    • for a /path/to/some/dir URL :
      • is the storage media actually mounted ?
  • OR : the Git repository you’re trying to pull from has several configured remotes — some of which that are intermittently available (only at home / only at work) — and you’re actually trying to pull from the wrong remote. Make sure you’ve not typed git pull origin master automatically

git clone fails : fatal: unable to access ‘ https://github.com/ . /. .git/ ‘: gnutls_handshake() failed: An unexpected TLS packet was received.

patch fragment without header + Your edited hunk does not apply during git add —interactive

Situation

Details

This answer has some interesting information about editing hunks (but not the answer to the current issue, though )

Solution

Possible cause Solution
a Git bug (sources: 1, 2) Don’t split + edit hunks, edit them directly.
My editor ( Emacs ) is configured to delete trailing whitespace before saving,
which deletes context lines from the patch (these lines contain only a single SPACE character)
(source)
  • disable this Emacs hook
  • use a different text editor :
    • export EDITOR= vim
    • alternate solution
  • in Emacs configuration file, replace (source) : with :

Git command fails : fatal: unable to access ‘ https:// git.domain.tld/path/to/myRepository/ ‘: server certificate verification failed.

Situation

git clone https:// git.domain.tld/path/to/myRepository/

Solution

  • This applies to any Git command, not only git clone.
  • To make this permanent :

git push origin master ends up with remote: error: refusing to update checked out branch: refs/heads/master

When trying to git push from a remote back to the origin , I get this error message :

As said by this error message : you just can NOT push to a non- bare Git repository (details).

Some solutions are still available :

  • pull from your origin instead of push ing from a remote
  • OR check out a different branch in the target repository, then push
  • OR make the original repository bare , and push whatever you like
  • OR set the receive.denyCurrentBranch in config as suggested to allow pushing to checked-out branches, and take care of the discrepancies
  • OR possibly even force push would work, I don’t suggest that

Your branch is ahead of ‘origin/master’ by n commits. after successfully pulling from origin to remote

Situation

Working with local and remote branches, when sitting on a remote branch and after pulling from origin to remote , git status says :

Details

On the remote , the commits I made on the origin are there. It looks like only the count of commits is wrong.

Solution

On the remote branch, run :

git pull complains Your local changes to ‘ myFile ‘ would be overwritten by merge. Aborting.

This error message is fairly explicit. To fix this :

  1. git stash : save your work in progress
  2. git pull -f : get updates from the repository
  3. git stash pop : apply the local changes on top of the update

Источник

Git — вопрос от новичка

Осваиваю git. В самом начале пути.

Читайте также:  Fatal error cstddef no such file or directory

Есть удаленный сервер. Есть локальный компьютер. Создал на сервере папку /home/alex/test/. В ней тестовый файл 1.test

Далее на сервере в консоли ввел команды: cd /home/alex/test/ git init git add . git commit

Далее на локальном компьютере ввел команду: git clone ssh://alex@123.45.678.910:22/home/alex/test/

Все успешно скопировалось на локальный компьютер в созданную папку test

Далее я на локальном компьютере переименовал файл 1.test в 2.test и выполнил команды git add . git commit

Далее я ввожу команду git push но получаю сообщение: fatal: Not a git repository (or any parent up to mount point /home) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

Такое же сообщение я получаю если изменяю файл на сервере, делаю commit а потом на локальном пытаюсь выполнить git pull, git fetch.

Перевод этого текста мне ничего не дает. В рунете информации я не нашел. Может кто подскажет что я делаю не так?

А git демон точно есть и запущен ?

нужно сделать git init?

google://git bare repository

а его разве нужно запускать если соединение по ssh ?

По-моему, ты просто умудрился из каталога test вывалиться в alex.

Это значит, что git не нашел директорию .git в текущей или родительских директориях. Проверь, где находишься, перед тем, как писать git push.

Далее я ввожу команду git push но получаю сообщение:

По дефолту git push в не-bare репозиторий не работает же (безотносительно твоей ошибки).

Я перешел из папки alex в test, и выполнил git push еще раз: Сейчас ошибка имеет такой вид:

Подсчет объектов: 2, готово. Delta compression using up to 4 threads. Сжатие объектов: 100% (2/2), готово. Запись объектов: 100% (2/2), 244 bytes | 0 bytes/s, готово. Total 2 (delta 0), reused 0 (delta 0) remote: error: refusing to update checked out branch: refs/heads/master remote: error: By default, updating the current branch in a non-bare repository remote: error: is denied, because it will make the index and work tree inconsistent remote: error: with what you pushed, and will require ‘git reset —hard’ to match remote: error: the work tree to HEAD. remote: error: remote: error: You can set ‘receive.denyCurrentBranch’ configuration variable to remote: error: ‘ignore’ or ‘warn’ in the remote repository to allow pushing into remote: error: its current branch; however, this is not recommended unless you remote: error: arranged to update its work tree to match what you pushed in some remote: error: other way. remote: error: remote: error: To squelch this message and still keep the default behaviour, set remote: error: ‘receive.denyCurrentBranch’ configuration variable to ‘refuse’. To ssh://alex@123.456.78.910:22/home/alex/test/.git ! [remote rejected] master -> master (branch is currently checked out) error: не удалось отправить некоторые ссылки в «ssh://alex@123.456.78.910:22/home/alex/test/.git»

Скажите, как я могу отправить изменения в серверный репозиторий?

Теперь вы можете создать пустой репозиторий для них, запустив git init с параметром —bare

Скажите, как я могу отправить изменения в серверный репозиторий?

Есть несколько вариантов:

  • Делай push в другую ветку (например, $ git push origin master:remote-master ), а затем делай merge/rebase.
  • Переключай текущую checked-out ветку в удалённом репозитории перед push’ем.
  • Используй bare-репозиторий.

remote: error: You can set ‘receive.denyCurrentBranch’ configuration variable to

remote: error: ‘ignore’ or ‘warn’

Неправда. Не работает только в зачекаутенную ветку.

Источник

Smartadm.ru
Adblock
detector