dropbox_如何将Dropbox与SVN或Git一起用于Cloud SCM

dropbox

Dropbox is a popular cloud-based storage and backup service. its success can be identified as maintaining a reliable service, and being available on every platform – including mobile ones.

Dropbox是一种流行的基于云的存储和备份服务。 它的成功可以被认为是维持可靠的服务,并且可以在包括移动平台在内的所有平台上使用。

In this article, I will explain how Dropbox can be used to manage the source code for small, personal projects. I’ll provide examples using both Git and Subversion.

在本文中,我将解释如何使用Dropbox来管理小型个人项目的源代码。 我将提供同时使用Git和Subversion的示例。

总览 (Overview)

So we all use Dropbox as a kind of virtual drive; a place to keep all the stuff that we want to have access to, from everywhere we go, and from any device. But what about our source code? Most developers will be familiar with the likes of Github, or Bitbucket for source management and revision control.

因此,我们所有人都将Dropbox用作一种虚拟驱动器。 一个可以存放我们想要访问的所有内容的地方,无论我们走到哪里,都可以从任何设备访问。 但是我们的源代码呢? 大多数开发人员会熟悉GithubBitbucket等用于源代码管理和版本控制的工具。

I’m not suggesting that Dropbox could replace either of those services of course. However, what about using it to look after small projects of your own? The kind of project where you still want to use version control, but where there is no need for the power of a service like Github?

我并不是说Dropbox当然可以取代其中任何一项服务。 但是,如何使用它来管理自己的小型项目呢? 您仍然想使用版本控制,但又不需要像Github这样的服务强大功能的项目?

Dropbox还没有版本控制权吗? (Doesn’t Dropbox already have revision control?)

Sort of. But it wouldn’t be suitable for version control. It’s more of a back up of each document/file you have stored. Also, you wouldn’t be able to commit and push to a repository if you relied just on that feature.

有点。 但这不适用于版本控制。 它更多地是存储的每个文档/文件的备份。 此外,如果仅依靠该功能,您将无法提交并推送到存储库。

Dropbox Revisions

Dropbox Revisions

投寄箱修订

Git入门 (Getting started with Git)

I’ll assume that you have a coding project that you want to use. If you haven’t already, initialise a Git repository while in the project folder from the console/command line:

我假设您有一个要使用的编码项目。 如果还没有,请从控制台/命令行在项目文件夹中初始化Git存储库:

git init

Add the files in your project:

在项目中添加文件:

git add .

Then commit the files:

然后提交文件:

git commit -am 'initial commit'

Everything so far has been local to your computer. Next, change directory into your dropbox folder, and create a folder to hold your Git projects. Being adventurous, I called mine ‘git_projects’:

到目前为止,所有内容都是本地计算机。 接下来,将目录更改为您的保管箱文件夹,并创建一个文件夹来保存您的Git项目。 冒险时,我称我为“ git_projects”:

cd ~/Dropbox
mkdir git_projects

Now you can switch back to the directory containing your actual code:

现在,您可以切换回包含实际代码的目录:

cd ~/sample_project

Next, we need to clone the project folder we just created in our Dropbox folder. We are going to clone this as a bare project so that we can push and pull to it. if you clone a project with a working tree already, it will cause complications with the push/pull process:

接下来,我们需要克隆刚刚在Dropbox文件夹中创建的项目文件夹。 我们将其克隆为一个裸项目,以便我们可以对其进行推拉。 如果您已经使用工作树克隆了一个项目,则将导致推/拉过程的复杂性:

git clone --bare . ~/Dropbox/git_projects/sample_project.git

If you haven’t added any code to your project yet, you will receive a warning that you have cloned an empty project. But that’s fine, you can add some files shortly. Next, we need to add our Dropbox project as a remote alias so that we can push to it:

如果尚未向项目添加任何代码,则会收到一条警告,提示您已克隆了一个空项目。 但这很好,您可以很快添加一些文件。 接下来,我们需要将Dropbox项目添加为远程别名,以便我们可以推送到它:

git remote add sample_project ~/Dropbox/git_projects/sample_project.git

Now you can add code and commit as normal. When you are ready to push to the Dropbox repository, you just do a:

现在,您可以正常添加代码并提交。 准备好推送到Dropbox存储库时,只需执行以下操作:

git push sample_project master

To work with the code from another computer, you can clone the project:

要使用另一台计算机上的代码,可以克隆项目:

git clone ~/Dropbox/git_projects/sample_project.git

Then work as normal, pushing back to the Dropbox repository when you have finished the updates.

然后正常工作,完成更新后将其推回Dropbox存储库。

颠覆也可以 (Subversion works too)

To achieve something similar with Subversion, the easiest way to get things working is to create the Dropbox directory first, convert it to a Subversion repository, and then checkout the trunk to add your code to.

要实现与Subversion类似的功能,最简单的方法是首先创建Dropbox目录,将其转换为Subversion存储库,然后检出主干以将代码添加到其中。

cd ~/Dropbox
mkdir subversion_projects
cd subversion_projects

Now we can make a repository for our specific project:

现在我们可以为我们的特定项目创建一个存储库:

svnadmin create sample_project

Then create the standard layout for a Subversion project. We’ll start with the trunk:

然后为Subversion项目创建标准布局。 我们将从树干开始:

svn mkdir file://localhost/Users/you/Dropbox/subversion_projects/sample_project/trunk -m 'repo layout'

If you are on Windows, you will find this article useful, even though it’s a bit dated now. You can also look at using TortoiseSVN to make your life easier.

如果您使用的是Windows,即使这篇文章过时了,您也会发现很有用。 您也可以看看使用TortoiseSVN简化生活。

We can continue to make the default layout:

我们可以继续进行默认布局:

svn mkdir file://localhost/Users/you/Dropbox/subversion_projects/sample_project/branches -m 'repo layout'
svn mkdir file://localhost/Users/you/Dropbox/subversion_projects/sample_project/tags -m 'repo layout'

Then, checkout the trunk:

然后,检出行李箱:

svn checkout file://localhost/Users/you/Dropbox/subversion_projects/sample_project/trunk svn_project

Noe you can continue to add code as normal. Once you have finished your updates, add any new files with svn add, and then commit the changes:

否,您可以继续正常添加代码。 完成更新后,请使用svn add添加所有新文件,然后提交更改:

svn commit -m 'latest updates'

Just as you can with the git example, you can simply checkout a working copy on another machine, add/edit code, and then commit back. Don’t forget to do an svn update when you use the original computer again.

就像git示例一样,您可以简单地在另一台机器上签出工作副本,添加/编辑代码,然后再提交。 当您再次使用原始计算机时,请不要忘记进行svn更新。

最后 (Finally)

Using Dropbox to act as a repository for Git and Subversion projects probably wouldn’t be a good idea for large teams. However, for your own projects, it’s a lot cheaper than using private repositories on Github for example. It also provides a way for you to work on your personal projects from different computers, whether your prefer Git or Subversion.

对于大型团队来说,使用Dropbox充当Git和Subversion项目的存储库可能不是一个好主意。 但是,对于您自己的项目,它比在Github上使用私有存储库便宜得多。 它还提供了一种方法,使您可以从不同的计算机(无论您喜欢Git还是Subversion)来处理个人项目。

If you have 2 Dropbox accounts: one for work, and one for personal use for example, you can still use the above procedures. Use the sharing facility that Dropbox has, to share a repo folder between accounts. You can then still add code, and commit, just as you would if you were using a service like Github.

如果您有2个Dropbox帐户:例如一个用于工作,一个用于个人使用,则仍然可以使用上述过程。 使用Dropbox拥有的共享工具,在帐户之间共享一个repo文件夹。 然后,您仍然可以添加代码并提交,就像使用Github这样的服务时一样。

翻译自: https://www.sitepoint.com/how-to-use-dropbox-with-svn-or-git-for-cloud-source-control-management/

dropbox

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值