Dan*_*vin 1384
我认为Dropbox上的Git很棒.我一直都在使用它.我有多台计算机(两台在家,一台在工作),我使用Dropbox作为中央裸存储库.由于我不想在公共服务上托管它,并且我无法访问我总是可以访问的服务器,因此Dropbox通过在后台同步(非常快)来处理这个问题.
安装程序是这样的:
~/project $ git init
~/project $ git add .
~/project $ git commit -m "first commit"
~/project $ cd ~/Dropbox/git
~/Dropbox/git $ git init --bare project.git
~/Dropbox/git $ cd ~/project
~/project $ git remote add origin ~/Dropbox/git/project.git
~/project $ git push -u origin master
Run Code Online (Sandbox Code Playgroud)
从那里,你可以克隆~/Dropbox/git/project.git你已经与你的Dropbox帐户相关联(或者与人共享这个目录),你可以做所有正常的Git操作,它们将自动同步到你的所有其他机器.
我写了一篇博客文章,On Version Control,(旧链接 死了)关于我的推理以及我如何设置我的环境,它基于我的Ruby on Rails开发经验,但它可以应用于任何事情,真的.
clu*_*clu 122
正确的方法是使用git-remote-dropbox:https://github.com/anishathalye/git-remote-dropbox
在Dropbox中创建自己的裸仓库会导致很多问题.Anish(图书馆的创建者)解释得最好:
这些问题的根本原因是Dropbox桌面客户端设计用于同步文件,而不是Git存储库.如果没有对Git存储库的特殊处理,它不会像Git那样保持相同的保证.远程存储库上的操作不再是原子操作,并发操作或不幸的同步时间可能导致存储库损坏.
传统的Git远程控制器在服务器端运行代码以使其正常工作,但我们不能这样做.
解决方案:可以正确解决此问题.即使有多个用户和并发操作,也可以将Git与Dropbox一起使用,并具有与传统Git遥控器相同的安全性和一致性保证!
对于用户来说,它就像使用git-remote-dropbox一样简单,它是一个Git远程助手,充当Git和Dropbox之间透明的双向桥接器,并保持传统Git远程的所有保证.它甚至可以安全地与共享文件夹一起使用,因此它可以用于协作(与无限合作者一起使用无限制的私人回购!).
使用远程帮助程序,可以将Dropbox用作Git远程并继续使用所有常规Git命令,如git clone,git pull和git push,一切都将按预期工作.
Bra*_*cox 89
这个答案基于Mercurial的经验,而不是Git,但是这种经验表明,如果甚至有可能在不同的时间从不同的机器更新同一个基于Dropbox的存储库,那么使用Dropbox就会要求损坏的存储库(Mac,在我的情况下,Unix,Windows).
我没有可能出错的完整列表,但这里有一个特定的例子.每台机器都有自己的行尾字符概念,以及如何在文件名中处理大写/小写字符.Dropbox和Git/Mercurial对此略有不同(我不记得确切的差异).如果Dropbox更新Git/Mercurial后面的存储库,那么presto就会破坏存储库.这种情况立即发生,并且不可见,所以在您尝试从中恢复之前,您甚至不知道您的存储库已损坏.
在从一个乱七八糟的东西中挖掘出这种方式之后,我一直在使用以下配方并取得了巨大的成功而且没有任何问题的迹象.只需将您的存储库移出Dropbox即可.将Dropbox用于其他一切; 文档,JAR文件,您喜欢的任何内容.并使用GitHub(Git)或Bitbucket(Mercurial)来管理存储库本身.两者都是免费的,所以这不会增加成本,现在每个工具都发挥其优势.
在Dropbox之上运行Git/Mercurial除了冒险之外什么都不会增加.不要这样做.
Eli*_*Eli 16
我不想把我的所有项目放在一个Git存储库下,也不想进入并为每个项目运行这个代码,所以我制作了一个Bash脚本来自动化这个过程.您可以在一个或多个目录上使用它 - 因此它可以为您执行此帖子中的代码,也可以一次在多个项目上执行此操作.
#!/bin/sh
# Script by Eli Delventhal
# Creates Git projects for file folders by making the origin Dropbox. You will need to install Dropbox for this to work.
# Not enough parameters, show help.
if [ $# -lt 1 ] ; then
cat<<HELP
projects_to_git.sh -- Takes a project folder and creates a Git repository for it on Dropbox
USAGE:
./projects_to_git.sh file1 file2 ..
EXAMPLES:
./projects_to_git.sh path/to/MyProjectDir
Creates a git project called MyProjectDir on Dropbox
./projects_to_git.sh path/to/workspace/*
Creates a git project on Dropbox for every folder contained within the workspace directory, where the project name matches the folder name
HELP
exit 0
fi
# We have enough parameters, so let's actually do this thing.
START_DIR=$(pwd)
# Make sure we have a connection to Dropbox
cd ~
if [ -s 'Dropbox' ] ; then
echo "Found Dropbox directory."
cd Dropbox
if [ -s 'git' ] ; then
echo " Dropbox Git directory found."
else
echo " Dropbox Git directory created."
mkdir git
fi
else
echo "You do not have a Dropbox folder at ~/Dropbox! Install Dropbox. Aborting..."
exit 0
fi
# Process all directories matching the passed parameters.
echo "Starting processing for all files..."
for PROJ in $*
do
if [ -d $PROJ ] ; then
PROJNAME=$(basename $PROJ)
echo " Processing $PROJNAME..."
# Enable Git with this project.
cd $PROJ
if [ -s '.git' ] ; then
echo " $PROJNAME is already a Git repository, ignoring..."
else
echo " Initializing Git for $PROJNAME..."
git init -q
git add .
git commit -m "Initial creation of project." -q
# Make the origin Dropbox.
cd ~/Dropbox/git
if [ -s $PROJNAME ] ; then
echo " Warning! $PROJNAME already exists in Git! Ignoring..."
else
echo " Putting $PROJNAME project on Dropbox..."
mkdir $PROJNAME
cd $PROJNAME
git init -q --bare
fi
# Link the project to the origin
echo " Copying local $PROJNAME to Dropbox..."
cd $PROJ
git remote add origin "~/Dropbox/git/$PROJNAME"
git push -q origin master
git branch --set-upstream master origin/master
fi
fi
done
echo "Done processing all files."
cd $START_DIR
Run Code Online (Sandbox Code Playgroud)
teh*_*aus 16
关于使用Dropbox的小团队:
如果每个开发人员在Dropbox上都有他们自己的可写裸存储库,这只能提供给其他开发人员,那么这有助于代码共享而不会有腐败风险!
然后,如果您想要一个集中的"主线",您可以让一个开发人员从他们自己的仓库管理所有推送.
Coy*_*e21 15
我不认为使用Git和Dropbox是可行的方法......只要想想两者的特点:
Git的方法:
Dropbox的:
如果你担心分享你的一些文件,为什么不加密呢?然后你可以获得Dropbox到Git的最大优势,就是拥有公共和私人文件......
mer*_*011 15
It is now 2015, and as of three days ago, a new tool based on Dropbox API v2 has been created to safely use git on Dropbox. It works against the API rather than using the desktop client, and correctly handles multiple simultaneous pushes to a repository hosted in a shared folder.
一旦配置,它允许一个人设置一个git遥控器,就像任何其他git遥控器一样.
git clone "dropbox::/path/to/repo"
git remote add origin "dropbox::/path/to/repo"
Run Code Online (Sandbox Code Playgroud)
我使用Mercurial(或Git)+ TrueCrypt + Dropbox进行加密远程备份.
最酷的是,如果修改了一小部分代码,Dropbox不会同步整个TrueCrypt容器.同步时间大致与更改量成比例.即使它是加密的,TrueCrypt + Dropbox的组合也可以很好地利用分组密码+块级同步.
其次,单片加密容器不仅增加了安全性,还减少了存储库损坏的可能性.
警告:但是,在Dropbox运行时,您必须非常小心未安装容器.如果2个不同的客户端为容器签入不同的版本,解决冲突也是一种痛苦.因此,它仅适用于使用它进行备份的单个人,而不适用于团队.
建立:
preserve modification timestamp*.用法:
PS取消选中preserve modification timestamp告知保管箱文件已被修改且应该同步.请注意,即使您不更改其中的任何文件,安装容器也会修改时间戳.如果您不希望发生这种情况,只需将卷安装为read-only
我喜欢Dan McNevin的答案!我现在也在一起使用Git和Dropbox,我在.bash_profile中使用了几个别名,所以我的工作流程如下所示:
~/project $ git init
~/project $ git add .
~/project $ gcam "first commit"
~/project $ git-dropbox
Run Code Online (Sandbox Code Playgroud)
这些是我的别名:
alias gcam='git commit -a -m'
alias gpom='git push origin master'
alias gra='git remote add origin'
alias git-dropbox='TMPGP=~/Dropbox/git/$(pwd | awk -F/ '\''{print $NF}'\'').git;mkdir -p $TMPGP && (cd $TMPGP; git init --bare) && gra $TMPGP && gpom'
Run Code Online (Sandbox Code Playgroud)
我们在共享文件夹上使用此方法(在Dropbox中创建裸存储库).
一小组开发人员可以从该同步的存储库中获取并创建一个本地克隆.一旦工作单元完成,我们就会回到原点.
我遗漏的一件事是,一旦推送到原点,就可以通过变更集信息发送电子邮件.我们正在使用Google Wave手动跟踪更改.
我一直以推荐的方式使用Mercurial,并敦促您保持谨慎,特别是如果任何机器不同的话.Dropbox论坛充满了对自发出现的神秘文件名案例问题的抱怨.Hg(我认为Git)在常规签到期间不会注意到或抱怨,并且当你试图将它用于真实时它会抱怨腐败的回购时你只能听到腐败.坏消息.希望我能更具体地解决这个问题及其解决方法; 我还在努力从这个烂摊子中挖掘出来.
小智 5
还有一个开源项目(跨平台[Linux,Mac,Win]脚本的集合),它使用少量(3-4)命令完成存储库管理的所有细节.
https://github.com/karalabe/gitbox/wiki
示例用法是:
$ gitbox create myapp
Creating empty repository...
Initializing new repository...
Repository successfully created.
$ gitbox clone myapp
Cloning repository...
Repository successfully cloned.
Run Code Online (Sandbox Code Playgroud)
正常的git用法之后:
$ echo “Some change” > somefile.txt
$ git add somefile.txt
$ git commit –m “Created some file”
$ git push
Run Code Online (Sandbox Code Playgroud)
查看项目Wiki和手册以获取完整的命令参考和教程.
| 归档时间: |
|
| 查看次数: |
280546 次 |
| 最近记录: |