git学习笔记(二)

  1. 解决无法向新建git仓库推送分支的问题
  • 问题描述: 在服务器新建git仓库后无法向git推送分支

  • 报错信息

      Compressing objects: 100% (1372/1372), done.
      remote: fatal: Unable to create temporary file 'some-repository.git/.git/./objects/pack/tmp_pack_XXXXXX': Permission denied
      fatal: sha1 file '' write error: Broken pipe
      error: failed to push some refs to 'git@somehost:/some-repository.git'
    
  • 出错原因

    远程仓库未开放

  • 解决方案:

    • 首先开放远程仓库:
    git config core.sharedRepository
    
    • 然后修改权限:
    chgrp -R git .
    chmod -R g+rwX .
    find . -type d -exec chmod g+s '{}' +
    
  • 再次推送:

    To somehost:some-repository.git
     * [new branch]      master -> dev
    

友情提示: 向远程仓库已检出的分支发起推送也会推送失败

```
remote error: refuse to update checked out branch: refs/heads/master
remote error: ...
```

你可能感兴趣的:(git学习笔记(二))