需要Git Setup(远程和本地repo)建议

7 git installation

我买了一个个人开发盒,用于部署我在笔记本电脑上创建的东西.我认为使用Git进行代码管理是个好主意.我的想法是,我将继续在我的笔记本电脑上提交,并在需要时,将更改推送到远程开发框.

  1. 我在盒子上初始化了一个Git repo
  2. 克隆在我的笔记本电脑上.
  3. 但在做完之后git push我得到了这个错误:

    remote:错误:拒绝更新签出分支:refs/heads/master remote:错误:默认情况下,更新非裸存储库中的当前分支:错误:被拒绝,因为它会使索引和工作树不一致remote:错误:你推了什么,并且需要'git reset --hard'才能匹配

我知道远程回购不是裸露的.

我想问一下,采用我的设置的唯一方法是:

  1. 在Server上初始化一个裸仓库
  2. 在我的笔记本电脑上克隆它
  3. 将新文件添加到本地笔记本电脑仓库并提交文件
  4. 推送到远程开发盒仓库

即使这个设置给我错误:

No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

编辑

我试过了

git push origin master
Run Code Online (Sandbox Code Playgroud)

得到此错误:

error: unable to create directory for .git/refs/remotes/origin/master
error: Cannot lock the ref 'refs/remotes/origin/master'.
Run Code Online (Sandbox Code Playgroud)

愚蠢的我...我认为它sudo就像在

sudo make me intelligent

syk*_*ora 10

正如你所说,第一条消息是因为遥控器不是一个简单的回购.

第二条消息是因为您创建的裸仓库没有分支开头.克隆存储库并签出工作副本时,它会为您创建主分支.但是当你试图推动时,远程仓库上没有主分支,所以它会抱怨.

尝试使用git push origin master(或任何你的遥控器),它应该为你在遥控器上创建分支.