[英]Git pushing to correct remote repo?
在我的共享主机目录中,我在git目录中有一个flask应用程序:
username@so6 [~/domains/mi]# ls -la
total 88
drwxr-xr-x 7 username username 4096 Jun 28 12:30 ./
drwxr-xr-x 19 username username 4096 Jun 28 12:30 ../
-rw-rw-r-- 1 username username 59 Jun 28 12:30 .bowerrc
drwxrwxr-x 5 username username 4096 Jun 28 12:30 .git/
-rw-rw-r-- 1 username username 400 Jun 28 12:30 .gitignore
drwxrwxr-x 3 username username 4096 Jun 28 12:30 .idea/
-rw-rw-r-- 1 username username 8192 Jun 28 12:30 dev.db
-rw-rw-r-- 1 username username 2528 Jun 28 12:30 manage.py
drwxrwxr-x 3 username username 4096 Jun 28 12:30 migrations/
drwxrwxr-x 8 username username 4096 Jun 28 12:30 myflaskapp/
我想从本地副本中推送更改,所以尝试了:
$ git push shared master
username@mydomain.net's password:
stdin: is not a tty
Counting objects: 28, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (21/21), done.
Writing objects: 100% (21/21), 3.47 KiB | 0 bytes/s, done.
Total 21 (delta 17), 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://username@mydomain.net:/home/username/domains/mi/.git
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'ssh://username@mydomain.net:/home/username/domains/mi/.git'
阅读我要拉然后推的错误消息,我尝试过:
$ git pull shared master
From ssh://mydomain.net:/home/username/domains/mi/
* branch master -> FETCH_HEAD
Already up-to-date.
现在我想知道我的远程URL是否设置正确。 shared设置为'ssh://username@mydomain.net:/home/username/domains/mi/.git',这看起来正确吗?
顺便说一句,我跑了
~/domains/mi git reset --hard
然后试图再次推动。 没有变化,我得到同样的错误。
编辑:
$ git remote show shared
user@domain.net's password:
stdin: is not a tty
* remote shared
Fetch URL: ssh://username@domain.net:/home/user/domains/mi/.git
Push URL: ssh://username@domain.net:/home/user/domains/mi/.git
HEAD branch: master
Remote branch:
master new (next fetch will store in remotes/shared)
Local ref configured for 'git push':
master pushes to master (fast-forwardable)
您正在尝试更改非裸存储库的头分支。 通常,远程存储库是裸露的,这意味着它没有工作树,因为没有人直接在其上工作,而仅将分支推送到它。
检查哪个存储库
git remote show shared
推送到共享(master1)上的其他(非当前)分支
git push shared master:master1
或者您可以转到“共享”并更改其当前分支,或者使整个存储库裸露。
如果您已将全局配置设置为接受ssh密钥进行身份验证,则不应使用用户名作为URL。 您应该使用git
用户。 您还应该在冒号后面有一个端口号,因为这是通过ssh访问系统的方式。 假设您的端口号是8080
,请尝试以下操作: ssh://git@mydomain.net:8080/home/username/domains/mi/project_name.git
。
通常,您通常也希望URL中包含项目名称,而不仅仅是结尾处的.git
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.