回答
如果您可以访问到共享目录下,你可以(见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
这将创建一个bare repo,在本地回购为“桌面”引用。
既然是裸露的,你可以(如果需要的话,以及来自它拉)推到它
git push desktop
随着ProGit book mentions,混帐不支持的文件协议:
最基本的是本地协议,其中远程存储库位于磁盘上的另一个目录中。
如果您团队中的每个人都可以访问共享文件系统(如NFS挂载),或者每个人都登录到同一台计算机的可能性较小,则通常会使用这种方式。
这是我写的脚本来做这件事。该脚本处理的新的git回购
- 我所有的常规的初始化将创建的.gitignore文件
- 初始化git的
- 在服务器上创建裸git仓库
- 树立本地的git回购推到远程回购
你一定要修改它适合你的任何设置,特别是如果你正在处理Windows笔记本电脑/台式机。
以下是完整的脚本:
#!/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/
我会建议在你的答案中全面复制你的脚本(因为它不是太大)。一旦堆栈溢出发布下一个cc-wiki转储(http://blog.stackoverflow.com/2009/06/stack-overflow-creative-commons-data-dump/),您确定此脚本将*始终*可用。否则,+1 – VonC 2010-05-22 12:59:42
最简单的(不是最好的)方法是通过局域网共享资源库目录,并使用Git的file://
协议(见man git
)。
对我来说,最好的方法是使用gitolite
(详细说明请参见gitolite docs)。
- 1. 如何从另一台计算机触发“git pull”,而另一台计算机又推送到bitbucket?
- 2. 如何从另一台机器推送时更新本地git?
- 3. 将Maven存储库迁移到另一台计算机
- 4. 将Maven存储库复制到另一台计算机
- 5. 如何将数据库数据安全地从一台计算机发送到另一台计算机?
- 6. 如何安全地推送到本地git存储库?
- 7. 如何从另一台计算机上的本地存储库中提取?
- 8. 从一台机器到另一台机器的Git存储库
- 9. 将多个Git存储库推送到一个存储库
- 10. 如何从另一台计算机从git存储库获取文件
- 11. 无意中将代码从一个git存储库推送到另一个git存储库地址
- 12. 如何从一台机器的git存储库克隆到另一台机器?
- 13. Git从多台机器推送到Assembla存储库
- 14. 将本地数据库从一台计算机复制到另一台
- 15. 如何使用java将文本数据从一台计算机无线发送到另一台计算机?
- 16. 将存储导出到另一台计算机
- 17. 如何将击键发送到另一台计算机
- 18. 将ASP.NET文件从本地计算机传输到另一台计算机
- 19. 如何将本地更改推送到bitbucket上的远程git存储库
- 20. 如何将我的git svn配置文件推送到另一个存储库?
- 21. 如何将我的本地存储库推送到远程存储库?
- 22. 我已经从另一个人的存储库克隆了,现在我该如何将代码从本地计算机推送到我自己的存储库?
- 23. 如何将更新从本地存储库推送到BitBucket?
- 24. 如何将本地存储库推送到远程使用“SourceTree”
- 25. 将数据库从一台计算机复制到另一台
- 26. Java GitHub API -org.kohsuke.github将存储库克隆到本地计算机
- 27. 推送到通过HTTP本地托管的git存储库
- 28. 如何将Git存储库的版本与另一个版本的Git存储库链接Git存储库
- 29. 从本地存储库仅将一个文件推送到GitHub
- 30. 从另一台计算机连接到Windows本地主机(IIS)
git应该在superusers.com – vodkhang 2010-05-22 12:18:11
你看了man page吗?键入'git help push'? – crazyscot 2010-05-22 12:28:17
@vodkhang:不,它不应该超级用户。它是开发人员工具箱及其编程环境的重要组成部分。 – VonC 2010-05-22 12:47:04