I can’t push in GIT repose

Asked

Viewed 245 times

4

I have a GIT repository on an SSH server and when trying to push, the following happens:

Counting objects: 16, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (14/14), done.
Writing objects: 100% (16/16), 1.35 KiB | 1.35 MiB/s, done.
Total 16 (delta 9), reused 0 (delta 0)
error: unable to write sha1 filename ./objects/da/ffdcd5a57dd3f3b9d8aed54e4439dc0fe0a558: 
Permissão negada
error: unable to write sha1 filename ./objects/75/aa2521a79e4d6af862dce838331155aed96550: 
Permissão negada
error: unable to write sha1 filename ./objects/1c/0a5357051d2b326dc77e7e53fe7d1384c86ad1: 
Permissão negada
To ssh://192.168.0.5/opt/project.git
! [remote rejected] master -> master (unable to migrate objects to permanent storage)
error: failed to push some refs to 'ssh://192.168.0.5/opt/project.git'

I noticed that in the remote repository, these folders are created with write permission only for those who created them. That is if someone else pushed and created these folders with permission only for them, when I try to push and overwrite one of these folders I won’t be able.

[EDIT] I realized that in my local repository these folders are created with files with permission only for those who created them, so when I push they go together and if other users want to overwrite they will not be able

How to make these folders not be created with permission only for the owner?

  • Have you tried using a git push --force ? With me it worked in a situation, but be aware that by doing so it will delete everything in the current repository and replace it with content you are trying to upload.

  • You have configured SSH Keys?

2 answers

5


At the time of initializing your repository you should instruct the git to create in shared mode and how it should be done. There are some sharing modes and I suspect that the standard (group) is the most suitable for you:

$ git init --bare --shared=group opt/project.git
$ chgrp -R devs opt/project.git

This will create a new repository shared between the user group devs in the directory opt/project.git.

If you don’t want to create a repository from scratch, run the following commands inside the directory opt/project.git:

$ chgrp -R devs .
$ chmod -R g+rw .
$ find -type d -exec chmod g+s {} +
$ git config core.sharedRepository group

To learn more about sharing modes just read the manual of git init.

  • I already tried, I noticed that here in my local repository is that folders are created, with read-only permission and when I push they go along with read permission, without letting other users overwrite the folder

  • Yes, to fix it you should run the commands I listed in the last block (where you have the calls chgrp, chmod, etc.)

  • Solved, thank you!

-1

You need to know your level of permission in this project. The project owner has full permission so he can create the folders and decide who can create these folders as well. The ideal is to ask his permission. Depending on your level you can’t push the main project, just the branch you created when you pulled.

  • 3

    it’s not about that - it’s about Unix file permissions on the git server.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.