Git Failure Push: Refusal to update a verified branch

Possible duplicate:
git push error '[remote reject] master β†’ master (the branch is currently checked)'

I try to push my repository to "origin", but I get this error when I run "git push"

Counting objects: 5, done. Delta compression using up to 4 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (4/4), 485 bytes, done. Total 4 (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 Auto packing the repository for optimum performance. 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'. /usr/local/git/libexec/git-core/git-sh-setup: Zeile 235: uname: Kommando nicht gefunden. warning: There are too many unreachable loose objects; run 'git prune' to remove them. To ssh:// XXXX@XXXXXX.typo3server.info /html/typo3 ! [remote rejected] master -> master (branch is currently checked out) error: failed to push some refs to 'ssh:// XXXXXXX@XXXXXX.typo3server.info /html/typo3' 

What's wrong?

+6
source share
1 answer

You are trying to click on a non-bare repo (i.e. a repo with a working tree, just like your local clone), but nothing has been done on the other end to take this into account specifically.

It looks like you are trying to deploy your git push site. Here's how to do it:

  • Git gives you to ignore the error message now by running this in a repo on your server:

     git config receive.denyCurrentBranch ignore 

    This says git "I will work, trust me."

    Now, if you click, it will update the repo, but the index and working copy will be left untouched. This means that it will always look like you made changes to bring back everything you clicked.

    We need a way to update the index and working copy whenever a click occurs. Looks like it's time to ...

  • Set up a post-receive hook. Add the .git/hooks/post-receive file to the server repository:

     #!/bin/bash # Drop the env var given to post-receive by default, as it'll mess up our # attempts to use git "normally." export -n GIT_DIR # Move back to the base of the working tree. cd .. # *Drop all changes* to index and working tree. git reset --hard 

    Please note that this assumes that you always want your tracked changes to be live - everything that you changed directly on the live site will disappear the next time you click (with the exception of unnecessary files, but you should not have one).

I add git status at the end so that I can see what is on the ground after the push (as it is passed back to the client) - it is especially important that I can catch the irreproducible files and add them to .gitignore or track them.

Remember to mark post-receive as executable!


Also: why don't you have files without a trace?

  • Rollback feature: this is for deploying a live site. If you want to really roll back a failed deployment, you will need everything that comes together to deploy.

    This definitely includes the core CMS. Right now, this is only on the server and it is not being tracked, so you have no hope of detecting an error.

  • Redeployability: if your hard drive of your server goes down, you can unzip the main CMS, re-apply the git repository to it and hope that it works.

  • The opportunity to notice that it is not tracked by accident: if you have several dozen irreproducible files, and all of them are β€œdesigned” in order not to track them, it is easy for a new file to sneak in and get lost in noise.

    If your git status clean by default , then you will see unexpected irreproducible files as soon as they appear.

+17
source

Source: https://habr.com/ru/post/920032/


All Articles