64

ラップトップにローカルの Git リポジトリをセットアップしています。デスクトップにプッシュしたいと思います。

どうやってやるの?

4

3 に答える 3

57

共有ディレクトリにアクセスできる場合は、次のことができます (git cloneおよびを参照git remote)。

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

これにより、ローカルリポジトリで「デスクトップ」として参照される裸のリポジトリが作成されます。
裸なので、プッシュできます(必要に応じてプルもできます)。

git push desktop

ProGitの本で言及されているように、git はファイル プロトコルをサポートしています。

最も基本的なプロトコルはローカルプロトコルで、リモート リポジトリはディスク上の別のディレクトリにあります。
これは、チームの全員が NFS マウントなどの共有ファイルシステムにアクセスできる場合、または全員が同じコンピューターにログインする可能性が低い場合によく使用されます。

于 2010-05-22T12:38:21.227 に答える
5

これがまさにこのことをするために私が書いたスクリプトです。スクリプトは、新しいgitリポジトリの通常の初期化をすべて処理します

  1. .gitignoreファイルを作成します
  2. .gitを初期化します
  3. サーバー上にベアgitリポジトリを作成します
  4. そのリモートリポジトリにプッシュするようにローカルgitリポジトリを設定します

http://gist.github.com/410050

特にWindowsラップトップ/デスクトップを扱っている場合は、設定に合わせて変更する必要があります。

完全なスクリプトは次のとおりです。

#!/bin/bash
# Create Git Repository
# created by Jim Kubicek, 2009
# jimkubicek@gmail.com
# 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 $REPLOGIN@$REPADDRESS:$REPLOCATION/
rm -rf $TEMPREP

# Set up the origin for the project
echo "Linking current repository to remote repository"
git remote add origin $REPLOGIN@$REPADDRESS:$REPLOCATION/$REPNAME.git/
于 2010-05-22T12:54:57.187 に答える
2

最も簡単な (最善ではない) 方法は、LAN 経由でリポジトリ ディレクトリを共有し、git のfile://プロトコルを使用することです (「参考文献」を参照man git)。

私にとって、最良の方法は使用することですgitolite(詳細な手順については、 gitolite のドキュメントを参照してください)。

于 2010-05-22T20:48:49.207 に答える