我在我的笔记本电脑上设置了一个本地的Git仓库,我想将它推送到我的台式机上。
我应该如何操作呢?
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
这将创建一个裸库, 在您的本地存储库中引用为"desktop"。
由于它是裸的,您可以向其推送(如果需要,也可以从中拉取)
git push desktop
正如ProGit书籍所提到的那样,git支持文件协议:
最基本的是本地(Local)协议,在该协议中,远程仓库位于磁盘上的另一个目录中。
如果你的团队中的每个人都可以访问共享文件系统(例如NFS挂载),或者在每个人都登录同一台计算机的较不可能的情况下,通常会使用此协议。
git clone . ssh://user@desktop:git/remoteRepo.git
会在名为ssh:/user@desktop:git/remoteRepo.git的子目录中创建一个本地repo,而我想要一个远程repo - 这就是整个问题所在。那么,我该如何通过ssh连接到远程机器,而不是创建一个名为ssh的目录呢? - AstroFloydssh://user@desktop/full/path/to/git/remoteRepo.git
(所以没有“:`”)。 - VonCgit clone . ssh://user@desktop/home/user/path/to/git/remoteRepo.git
)会在我的本地框中的当前目录下创建一个子目录树 ./ssh:/user@desktop/home/user/path/to/git/remoteRepo.git
... :( - AstroFloyd/home/user/path/to/git/remoteRepo.git
是存在的吗? - VonC#!/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/
最简单的(不是最好的)方法是通过局域网共享存储库目录,并使用git的file://
协议(请参见man git
)。
对我来说,最好的方法是使用gitolite
(有关详细说明,请参见gitolite文档)。
git help push
命令了吗? - crazyscot