Cannot push after adding remote warehouse to git
漂亮男人
漂亮男人 2017-05-02 09:28:02
0
2
524

I have an Alibaba Cloud ECS (CentOS7), and I need to put the project on it, but I don’t want to go through github. I want to add the remote warehouse directly to the local git warehouse and push it directly to ECS.
First create the project directory in ECS and initialize the warehouse: $ git init
Add the remote warehouse to the local warehouse:

$ git remote add ECSmaster ssh://username@IP/~/path/.git

After adding it, it cannot be pushed. The error message is as follows:

$ git push -u ECSmaster master
username@IP's password:
Counting objects: 180, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (75/75), done.
Writing objects: 100% (180/180), 32.15 KiB | 0 bytes/s, done.
Total 180 (delta 104), reused 180 (delta 104)
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://username@IP/~/cloudNote/.git
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'ssh://username@IP/~/cloudNote/.git'


$ git remote show ECSmaster
username@IP's password:
* remote ECSmaster
  Fetch URL: ssh://username@IP/~/cloudNote/.git
  Push  URL: ssh://username@IP/~/cloudNote/.git
  HEAD branch: (unknown)

The above operations refer to this article: http://www.cnblogs.com/xiaoya901109/archive/2012/08/03/2620664.html

漂亮男人
漂亮男人

reply all(2)
过去多啦不再A梦

When initializing the warehouse on the server, you should add the --bare parameter
git init --bare

为情所困

Enter the following on the remote server:
git config 'receive.denyCurrentBranch' warn

This error is due to a protection measure of git master->master to avoid misoperation

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template