Git推动纠正远程回购?

时间:2016-06-30 16:03:01

标签: git

在我的共享主机目录中,我在git目录中有一个烧瓶应用程序:

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.

现在我想知道我的远程网址是否设置正确。 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)

2 个答案:

答案 0 :(得分:2)

您正在尝试更改非裸存储库的头部分支。通常远程存储库是裸的,这意味着它没有工作树,因为没有人直接使用它,而只是将分支推送到它。

检查哪个存储库

git push shared master:master1

要在共享(master1)上推送到另一个(非当前)分支

int i = 0;
foreach( Client c in clients){
   c.Id = i++;
}

或者您可以转到'共享'并更改其当前分支或使整个存储库裸露。

答案 1 :(得分:1)

如果您的全局配置设置为接受ssh密钥进行身份验证,则不应使用您的用户名作为URL。您应该使用git用户。您应该在冒号后面有一个端口号,因为这是通过ssh访问系统的方式。鉴于您的端口号为8080,请尝试以下操作:ssh://git@mydomain.net:8080/home/username/domains/mi/project_name.git

您通常也需要URL中的项目名称,而不仅仅是最后的.git