git push提示Read-only权限问题

今天git push时出现如下错误:


$ git push

warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

In Git 2.0, Git will default to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

[email protected]'s password:
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 322 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
error: unable to create temporary sha1 filename ./objects/e3: Read-only file sys
temerror: unpack failed: unpack-objects abnormal exit

fatal: failed to write object
To [email protected]:~/your-repositoryname.git
 ! [remote rejected] master -> master (n/a (unpacker error))

error: failed to push some refs to '[email protected]:~/your-repositoryname.git


根据错误提示知道,这是git库权限问题,解决办法如下:

1、首先在远程服务器上试试看,用mkdir能不能新建目录,

[[email protected]]:~# mkdir aa
mkdir: cannot create directory `aa': Read-only file system

如果提示 Read-only file system,可以尝试用 fsck -y 来修复



[[email protected]]:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
#              
proc            /proc           proc    nodev,noexec,nosuid 0       0
# / was on /dev/xvda1 during installation
UUID=8f91cd21-b0ca-45d7-88ba-616ddc4d37ec / ext4 errors=remount-ro,barrier=0 0 1
none                   /proc/xen               xenfs   defaults        0 0
/dev/xvdb1 /mnt ext3 barrier= 0 0 0

[[email protected]]:~# fsck -y
fsck from util-linux 2.20.1
e2fsck 1.42 (29-Nov-2011)
/dev/xvda1 contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Inode bitmap differences:  -400460
Fix? yes

Free inodes count wrong for group #48 (4, counted=5).
Fix? yes

Free inodes count wrong (1228211, counted=1228217).
Fix? yes


/dev/xvda1: ***** FILE SYSTEM WAS MODIFIED *****
/dev/xvda1: ***** REBOOT LINUX *****
/dev/xvda1: 82503/1310720 files (0.2% non-contiguous), 649348/5242368 blocks


[[email protected]]:~# reboot

重启后就能正常push了


2、如果在服务器终端使用mkdir能创建目录,说明仅仅是git仓库权限出现了问题,使用如下命令就可以解决:

chomod -R 777 your-repositoryname.git


你可能感兴趣的:(Git)