为什么不能将我的wordpress目录推送到远程github存储库?

时间:2017-01-01 12:07:23

标签: git github push

目标:将/ 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 init
4.git add *
5.git push origin master
错误:src refspec master与any匹配。
错误:未能将某些参考文献推送到原点'

感谢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存储库?

4 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

  1. 你没有git commit。
  2. 你没告诉git origin是什么意思。你必须:

    $ git remote add origin remote repository URL
    
  3. 请参阅说明here

答案 2 :(得分:0)

1.git push -f origin master 要解决问题:在{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

现在做得好。

答案 3 :(得分:0)

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>