<pre name="code" class="cpp"><span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">这段时间用gitosis搭建了git server,在使用过程中还有一些问题,这些问题的解决也是来自网络,就在这里整理一下。</span>
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">1 在客户端向服务端去push的时候出现</span>
insufficient permission for adding an object to repository database .git/objects
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">这个是因为权限有问题,比如在服务端创建工程时用的用户名是root,但是在clone时用的</span><span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">git clone git@xxxx:YYY.git</span>
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">修改后push用 git push origin master. 这样就出问题了,其实只要在服务端将工程的所有者修改即可</span>
<span style="font-family:Arial, Helvetica, sans-serif;"><span style="background-color: rgb(255, 255, 255);">方法如下,在服务端进入到git工程的父目录,用ls -la查看工程的所有者</span></span>
<span style="font-family:Arial, Helvetica, sans-serif;"><span style="background-color: rgb(255, 255, 255);">接着用 <span style="color: rgb(51, 51, 51); font-family: Georgia; font-size: 14px; letter-spacing: 1px; line-height: 20px;">sudo chown -R git:git YYY.git 即可</span></span></span>
<span style="font-family:Arial, Helvetica, sans-serif;"><span style="background-color: rgb(255, 255, 255);"><span style="color: rgb(51, 51, 51); font-family: Georgia; font-size: 14px; letter-spacing: 1px; line-height: 20px;">
</span></span></span>
<span style="font-family:Arial, Helvetica, sans-serif;"><span style="background-color: rgb(255, 255, 255);"><span style="color: rgb(51, 51, 51); font-family: Georgia; font-size: 14px; letter-spacing: 1px; line-height: 20px;">
</span></span></span>
<span style="font-family:Arial, Helvetica, sans-serif;"><span style="background-color: rgb(255, 255, 255);"><span style="color: rgb(51, 51, 51); font-family: Georgia; font-size: 14px; letter-spacing: 1px; line-height: 20px;">
</span></span></span>
<span style="font-family:Arial, Helvetica, sans-serif;"><span style="background-color: rgb(255, 255, 255);"><span style="color: rgb(51, 51, 51); font-family: Georgia; letter-spacing: 1px; line-height: 20px;"><span style="font-size: 14px;">2 在客户端push时出现</span></span></span></span><h1 itemprop="name" style="margin: 0px 0px 0.5em; padding: 0px; border: 0px; border-image-source: initial; border-image-slice: initial; border-image-width: initial; border-image-outset: initial; border-image-repeat: initial; line-height: 1.3; color: rgb(34, 34, 34); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;"><a target=_blank href="http://stackoverflow.com/questions/2816369/git-push-error-remote-rejected-master-master-branch-is-currently-checked" class="question-hyperlink" style="margin: 0px 0px 0.5em; padding: 0px; border: 0px; border-image-source: initial; border-image-slice: initial; border-image-width: initial; border-image-outset: initial; border-image-repeat: initial; cursor: pointer; color: rgb(34, 34, 34); text-decoration: none; line-height: 1.35; font-weight: normal;"><span style="font-size:14px;">Git push error '[remote rejected] master -> master (branch is currently checked out)'</span></a></h1>
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">这个是因为在工程初始化时方法不对,我的工程是在服务端创建的,也就是俗称的Remote(进入到工程中使用git init)</span>
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">这里只要再次进入到服务端的工程下,运行</span><span style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit; color: rgb(34, 34, 34); font-size: 13px; background-color: rgb(238, 238, 238);">git config --bool core.bare true 即可解决问题。</span>