repository - Using git on a single server, i.e. no truly remote origin -


this seems dumb, can't figure out. tons of instructions out there cloning or adding remote server, or pushing cloned repository. i'm trying figure out how set git repository in shared directory on server, , let other people collaborate clones in personal directories.

this i've tried:

abalter@u1:~$ mkdir mainrepo abalter@u1:~$ cd mainrepo/ abalter@u1:~/mainrepo$ echo "inital entry" > text.txt abalter@u1:~/mainrepo$ git init initialized empty git repository in /home/abalter/mainrepo/.git/ abalter@u1:~/mainrepo$ git add text.txt  abalter@u1:~/mainrepo$ git commit -m "initial commit" [master (root-commit) fb829d6] initial commit  1 file changed, 1 insertion(+)  create mode 100644 text.txt abalter@u1:~/mainrepo$ cd .. abalter@u1:~$ git clone mainrepo/ userrepo cloning 'userrepo'... done. abalter@u1:~$ cd userrepo/ abalter@u1:~/userrepo$ echo "users addition" >> text.txt  abalter@u1:~/userrepo$ git commit -am "users addition" [master 3d4ea94] users addition  1 file changed, 1 insertion(+) abalter@u1:~/userrepo$ git add remote origin ../mainrepo/ fatal: ../mainrepo/: '../mainrepo/' outside repository abalter@u1:~/userrepo$ git push origin master counting objects: 5, done. writing objects: 100% (3/3), 267 bytes | 0 bytes/s, done. total 3 (delta 0), reused 0 (delta 0) remote: error: refusing update checked out branch: refs/heads/master remote: error: default, updating current branch in non-bare repository remote: error: denied, because make index , work tree inconsistent remote: error: pushed, , require 'git reset --hard' match remote: error: work tree head. remote: error:  remote: error: can set 'receive.denycurrentbranch' configuration variable remote: error: 'ignore' or 'warn' in remote repository allow pushing remote: error: current branch; however, not recommended unless remote: error: arranged update work tree match pushed in remote: error: other way. remote: error:  remote: error: squelch message , still keep default behaviour, set remote: error: 'receive.denycurrentbranch' configuration variable 'refuse'. /home/abalter/mainrepo/  ! [remote rejected] master -> master (branch checked out) error: failed push refs '/home/abalter/mainrepo/' abalter@u1:~/userrepo$  

i'm missing step, don't know is.

edit realize should have been git remote add origin ../mainrepo.

abalter@u1:~/userrepo$ git remote add origin ../mainrepo fatal: remote origin exists. abalter@u1:~/userrepo$  

if exists, why can't push it?

the answer here no different setup on actual remote machines: repository push should1 --bare clone. instance, set things whole thing start making user repository (so can make initial commits):2

$ mkdir set-it-up && cd set-it-up $ git init [create , add files usual , then] $ git commit 

then move place want bare master repo, and, e.g.:

$ mkdir master-repo.git; cd master-repo.git; git init --bare 

(you may want add --shared or --shared=all, etc.; see the git init documentation). have bare—no work directory—repository, suitable both cloning-from , pushing-to.

to fill in, may fetch (manually) "set-it-up" repo:

git fetch /path/to/set-it-up 'refs/*:refs/*' 

at point it's safe remove "set-it-up" copy: cloning master-repo.git directory fresh clone in work, clone's origin set path of master-repo.git directory.

alternatively, in set-it-up repo, can add master-repo.git directory "origin" url, push.


1since git 2.5, it's possible make sensible things (for value of sensible) happen non-shared repository, bit more complex describe.

2you can make initial bare repository empty, if prefer. when cloning empty repository, git gripes bit, can work in clone , push fill in bare repository.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -