2010-05-22 29 views
53

Dizüstü bilgisayarımda yerel bir Git deposu kurulum var. Onu masaüstüme zorlamak istiyorum.Yerel bir Git deposunu başka bir bilgisayara nasıl geçirirsiniz?

Bunu nasıl yapabilirim? Paylaşılan dizine erişimi varsa

+4

git superusers.com adresinde olmalı – vodkhang

+1

Adam sayfasını okudun mu? yazdı 'git yardım push'? – crazyscot

+10

@vodkhang: hayır süper kullanıcıda olmamalı. Bir geliştirici araç kutusunun ve programlama ortamının önemli bir parçasıdır. – VonC

cevap

49

, siz (git clone ve git remote bakın):

git clone --bare /path/to/your/laptop/repo /shared/path/to/desktop/repo.git 
git remote add desktop /shared/path/to/desktop/repo.git 

"masaüstü" olarak yerel repo başvurulan bir bare repo oluşturmak edeceğimizi.

en temel şudur: çıplak olduğundan (gerekirse yanı sıra ondan çekme), ona ProGit book mentions olarak

git push desktop 

itebilir
, git dosya protokolünü desteklemiyor Uzak depodaki diskin başka bir dizinde bulunduğu Yerel protokolü.
Bu, genellikle ekibinizdeki herkesin NFS bağdaştırıcısı gibi paylaşılan bir dosya sistemine veya herkesin aynı bilgisayarda oturum açma olasılığının düşük olması durumunda kullanılır.

+0

'git push desktop',' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' 'itmek demektir. Bunun için bir 'çıplak' repo kesinlikle gerekli değildir. – Timo

+0

@Timo Evet, 2015'ten beri, çıplak olmayan bir repo mümkündür: https: // stackoverflow.com/a/30030236/6309 – VonC

5

İşte bu şeyi yapmak için yazdığım bir komut dosyası. senaryo .gitignore

  • oluşturduğunun kadar zorlamaya yerel git repo sunucuda çıplak git repo yaratır .git başlatır dosyası oluşturur yeni git repo
    1. hayatım zamanki başlatma kolları uzaktan repo o

    http://gist.github.com/410050

    kesinlikle bunu değiştirmek gerekecek Özellikle Windows dizüstü bilgisayar/masaüstü bilgisayar ile uğraşıyorsanız, sahip olduğunuz kurulum için uygun olanı seçin.

    #!/bin/bash 
    # Create Git Repository 
    # created by Jim Kubicek, 2009 
    # [email protected] 
    # http://jimkubicek.com 
    
    # DESCRIPTION 
    # Create remote git repository from existing project 
    # this script needs to be run from within the project directory 
    
    # This script has been created on OS X, so YMMV 
    
    ####### 
    # Parameters 
    REPLOGIN=#Login name 
    REPADDRESS=#Repo address 
    REPLOCATION=/Users/Shared/Development #Repo location 
    
    # The repo name defaults to the name of the current directory. 
    # This regex will accept foldernames with letters and a period. 
    # You'll have to edit it if you've got anything else in your folder names. 
    REPNAME=`pwd | egrep -o "/[a-zA-Z]+$" | egrep -o "[a-zA-Z\.]+"` 
    
    
    # If you have standard files/directories to be ignored 
    # add them here 
    echo "Creating .gitignore" 
    echo 'build/' >> .gitignore # The build directory should be ignored for Xcode projs 
    echo '.DS_Store' >> .gitignore # A good idea on OS X 
    
    # Create the git repo 
    echo "Initializing the repo" 
    git init 
    git add . 
    git commit -m "Initial commit" 
    
    # Copy the repo to the server 
    echo "Copying the git repo to the server $REPADDRESS" 
    TEMPREP="$REPNAME.git" 
    git clone --bare .git $TEMPREP 
    scp -r $TEMPREP [email protected]$REPADDRESS:$REPLOCATION/ 
    rm -rf $TEMPREP 
    
    # Set up the origin for the project 
    echo "Linking current repository to remote repository" 
    git remote add origin [email protected]$REPADDRESS:$REPLOCATION/$REPNAME.git/ 
    
  • +2

    Komut dosyanızı yanıtınıza tam olarak kopyalamanızı öneririz (çok büyük olmadığından). Bir kez Stack Overflow bir sonraki cc-wiki dökümü bırakın (http://blog.stackoverflow.com/2009/06/stack-overflow-creative-commons-data-dump/), bu betiğin * her zaman * olacağından eminsiniz . Aksi takdirde +1 – VonC

    2

    en kolay (iyi) yolu LAN üzerinden depo dizini paylaşan, ve git en file:// protokolü (man git bakınız) kullanmaktır:

    İşte tam komut dosyasıdır.

    Benim için en iyi yol gitolite'u kullanmaktır (ayrıntılı talimatlar için bkz. gitolite docs).

    İlgili konular