gitgit-init

Issue on git repository creation and accessibility using git


I had created created repository in UNIX machine,

$sudo git --bare init /var/repos/git/repo00001

Also I have done following commands executed for individual UNIX users,

$ git config --global user.email "MyfullName@mindtree.com"
$ git config --global user.name "Anand Sadasivam"

Under which directory I should be creating git repsitories, I have issue while check-in files. What should be the permission, user, group needs to be set for directory /var/repos/git on under which I am creating git repositories. At present its done under root privilege. Do I need to create separate UNIX user for git exclusively or any specific step or git command I have to follow to create user first before creating repository with git init

I had observed --bare for init created some basic structure under git repository. But when I did git clone my repository was empty.

Since I had used --bare, I could see folder structure created as follows,

# ls
HEAD  branches  config  description  hooks  info  objects  refs

Following are the commands I have done at git bash client side in Windows for initial check-in of some file,- Readme.txt

$ git clone anand@xx.xx.xx.xxx:/var/repos/git/repo00001
Cloning into 'repo00001'...
anand@xx.xx.xx.xxx's password:
warning: You appear to have cloned an empty repository.

<<I had created Readme.txt file under the present directory>>

$ git add Readme.txt

$ git status
On branch master

$ git commit -a
[master (root-commit) 8201309] Initial commit
 Committer: Anand Sadasivam <MMyEmpID@mindtree.com>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

    git config --global --edit

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+)
 create mode 100644 Readme.txt

$ git push origin master
anand@xx.xx.xx.xxx's password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 240 bytes | 120.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
error: remote unpack failed: unable to create temporary object directory
To xx.xx.xx.xxx:/var/repos/git/repo00001
 ! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to 'anand@xx.xx.xx.xxx:/var/repos/git/repo00001'

$ git show-ref
82013098f6801ea32bb620b612f779c8dade6d83 refs/heads/master

$ git push origin HEAD:master
anand@xx.xx.xx.xxx's password:
Counting objects: 3, done.
Writing objects: 100% (3/3), 240 bytes | 120.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
error: remote unpack failed: unable to create temporary object directory
To xx.xx.xx.xxx:/var/repos/git/repo00001
 ! [remote rejected] HEAD -> master (unpacker error)
error: failed to push some refs to 'anand@xx.xx.xx.xxx:/var/repos/git/repo00001'

Is this situation had arisen because Windows Settings been followed while git bash/gui client installation.

Or it is completely repository permission issue or repository creation user issue in UNIX


Solution

  • Repository should be created with --bare init --shared, I mean shared option should be additional and it should be done under,- say git login and sudo command must not be used. Once repository is created it will have rw access to group users.

    git@xx-xx-xx-xxx~/repos/repo00001$ ls -l
    total 32
    -rw-rw-r--  1 git git   23 Apr 20 06:44 HEAD
    drwxrwxr-x  2 git git 4096 Apr 20 06:44 branches
    -rw-rw-r--  1 git git   66 Apr 20 06:44 config
    -rw-rw-r--  1 git git   73 Apr 20 06:44 description
    drwxrwxr-x  2 git git 4096 Apr 20 06:44 hooks
    drwxrwxr-x  2 git git 4096 Apr 20 06:44 info
    drwxrwxr-x 62 git git 4096 Apr 25 08:22 objects
    drwxrwxr-x  4 git git 4096 Apr 20 06:44 refs
    

    Hence I have added all the users who needs to work with git repository to the group git, as you can see git:git is created repository and group git has rwx for most of the folder under which revisions going to be maintained.

    I've added & verified if the user is added to group,- git

    anand@capsimt00001:~$ sudo usermod -a -G git anand
    anand@capsimt00001:~$ groups
    anand geckoo git
    

    groups command displays all the group that particular user is belongs too.