簡體   English   中英

為什么無法將我的wordpress目錄推送到遠程github存儲庫中?

[英]Why can't push my wordpress directory into remote github repository?

目標:將/ var / www / html / wp推送到遠程github存儲庫中的newstart中。

ssh -T git@github.com
You've successfully authenticated, but GitHub does not provide shell access.

ssh和github處於良好狀態。

在偏遠地區

1.在github網頁上創建一個名為newstart的新項目。

在當地

2.cd / var / wwww / html / wp
3. sudo git初始化
4.git添加*
5. git push origin master
錯誤:src refspec master不匹配。
錯誤:無法將某些參照推送到“原點”

感謝ffledgling,添加了兩個命令。

git commit -m "First commit" 
git remote add origin git+ssh://git@github.com/someone/newstart.git 

git push origin master 
To git+ssh://git@github.com/someone/newstart.git 
 ! [rejected]        master -> master (fetch first) 
error: failed to push some refs to 'git+ssh://git@github.com/someone/newstart.git' 
hint: Updates were rejected because the remote contains work that you do 
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes 
hint: (e.g., 'git pull ...') before pushing again. 
hint: See the 'Note about fast-forwards' in 'git push --help' for details. 

如何現在將/ var / www / html / wp推送到遠程github存儲庫中?

  1. 您沒有git commit。
  2. 您沒有告訴git origin是什么意思。 您必須:

     $ git remote add origin remote repository URL 

在這里查看說明

1. git push -f origin master解決此問題: failed to push some refs to...在git push命令中使用-f參數failed to push some refs to...
2.將sudo git init更改為git init
為什么將sudo git init更改為git init

如果.git由sudo git init創建,則git push -f origin master將存在權限問題。

ls -al .
total 204
drwxr-xr-x  6 www-data www-data  4096 Jan  1 19:42 .
drwxr-xr-x  5 root     root      4096 Dec 12 22:27 ..
drwxr-xr-x  8 root     root      4096 Jan  1 21:02 .git

如果.git由git init創建,則git push -f origin master 不會有權限問題。

ls -al .
total 204
drwxr-xr-x  6 www-data www-data  4096 Jan  1 19:42 .
drwxr-xr-x  5 root     root      4096 Dec 12 22:27 ..
drwxr-xr-x  8 debian8  debian8   4096 Jan  1 21:02 .git

.git目錄的所有權將阻止執行git push -f origin master

現在做得好。

error: failed to push some refs to 'git+ssh://git@github.com/someone/newstart.git' 
hint: Updates were rejected because the remote contains work that you do 
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes 
hint: (e.g., 'git pull ...') before pushing again. 
hint: See the 'Note about fast-forwards' in 'git push --help' for details. 

上面的錯誤表明您當前未與遠程存儲庫同步。

同步

git pull --rebase

現在推送

git push origin <branch-name>

如果推送仍然不起作用,則說明該遙控器不存在。 添加它。

git remote add origin <path/to/your/remote/repo>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM