Git和Dropbox可以一起使用吗?
当前回答
现在是2014年,我已经使用Git和Dropbox大约一年半了,没有任何问题。 以下是几点:
我所有使用Dropbox的电脑都是Windows操作系统,不同版本(7到8)+ 1个mac。 我不与其他人共享存储库,所以我是唯一一个修改它的人。 git push推送到一个远程存储库,这样如果它损坏了,我可以很容易地恢复它。 我必须在C:\Users中使用mklink /D链接目标创建别名,因为一些库指向绝对位置。
其他回答
I've been using Mercurial in the recommended manner and urge that you be cautious, especially if any of the machines differ. The Dropbox fora are full of complaints of mysterious filename case problems turning up spontaneously. Hg (and I presume Git) won't notice or complain during routine checkins and you'll only hear about the corruption when it complains of a corrupt repo when you try to use it for real. Bad news. Wish I could be more specific about the problem and its workarounds; I'm still trying to dig out from this mess myself.
我不想把我所有的项目都放在一个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
这个答案是基于Mercurial的经验,而不是Git,但这个经验告诉我们,如果你在不同的时间从不同的机器(对我来说是Mac、Unix和Windows)更新相同的基于Dropbox的存储库,那么以这种方式使用Dropbox会导致存储库损坏。
I don't have a complete list of the things that can go wrong, but here's a specific example that bit me. Each machine has its own notion of line-ending characters and how upper/lower case characters are handled in file names. Dropbox and Git/Mercurial handle this slightly differently (I don't recall the exact differences). If Dropbox updates the repository behind Git/Mercurial's back, presto, broken repository. This happens immediately and invisibly, so you don't even know your repository is broken until you try to recover something from it.
在用这种方法解决了一次混乱之后,我一直在使用下面的食谱,而且非常成功,没有任何问题的迹象。只需将存储库移出Dropbox。其他事情都用Dropbox;文档,JAR文件,任何你喜欢的东西。并使用GitHub (Git)或Bitbucket (Mercurial)来管理存储库本身。这两种工具都是免费的,所以不会增加成本,而且现在每种工具都发挥了自己的优势。
在Dropbox上运行Git/Mercurial除了风险什么都不会增加。不要这样做。
对于使用Dropbox的小型团队:
如果每个开发人员在Dropbox上都有自己的可写裸存储库,这只对其他开发人员开放,那么这就有利于代码共享而没有损坏的风险!
然后,如果你想要一个集中的“主线”,你可以让一个开发人员从自己的回购中管理所有推送。
在不使用第三方集成工具的情况下,我可以稍微改善一下条件,并使用DropBox和其他类似的云磁盘服务,如带Git的SpiderOak。
我们的目标是避免在这些文件修改的中间同步,因为它可以上传一个部分状态,然后下载回来,完全破坏你的git状态。
为了避免这个问题,我做了:
使用git Bundle create my_repo将我的git索引捆绑在一个文件中。git——所有。 为文件监控设置一个延迟,例如5分钟,而不是瞬间。这降低了DropBox在更改过程中同步部分状态的机会。它在动态修改云磁盘上的文件时也有很大帮助(比如即时保存笔记应用程序)。
它并不完美,因为不能保证它不会再次弄乱git状态,但它有帮助,目前我没有遇到任何问题。
推荐文章
- 将文件的当前工作副本与另一个分支提交的副本区别对待
- 配置Git接受特定https远程的特定自签名服务器证书
- 如何将一个特定的提交从一个分支合并到Git中的另一个分支?
- 通过SSH配置Git登录一次
- 从pull请求中删除一个修改过的文件
- 如何使用Git恢复
- 如何提交没有变化和新的消息?
- 找到Git分支创建者
- 下载GitHub项目的最快方式
- git索引到底包含什么?
- 以树形输出git分支
- 如何点Go模块的依赖在Go。Mod到回购中的最新提交?
- 为什么调用git分支——unset-upstream来修复?
- Windows git“警告:LF将被CRLF取代”,这是警告尾巴向后吗?
- git中的哈希冲突