简体   繁体   中英

Using git to store repository in /opt/ for all users?

I have several users on the same linux machine to which several people remote to, and we have a software project we are working on.

How do I keep main repository in /opt (eg /opt/GitRepo/project).. and let everyone else have a brand in their local /home/user directory?

I have tried to clone the directory, but I am getting error when I am trying to push back the changes:

cd /home/user1/localGit/    
git clone /opt/GitRepo/project

After I make changes in that local copy and try to do git push

Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 299 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To /opt/GitRepos/project/
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '/opt/GitRepos/project/

The shared repository in /opt/GitRepo/project should be a "bare" repository. This essentially means that it contains only what you would normally find in the .git directory, and has no working tree; see here for a discussion.

You can create a bare clone like so:

git clone --bare <address> <target>

Or to initialise an empty bare repository:

git init --bare

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM