[英]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.