Setup a Git Repository in iCloud Drive

原文地址

https://winterbe.com/posts/2014/11/27/setup-icloud-git-repository/

Mac OSX is your preferred operation system as a developer? Then chances are good that you already use iCloud. Apple introduced iCloud Drive with OSX 10.10 (Yosemite) which grants you direct access to your remote iCloud folder. Finally you can move files directly between your local harddrive and iCloud back and forth.

iCloud Drive can easily be used as remote storage for your private git repositories. You don't have to use third-party services like Dropbox anymore. Read further for a quick and simple 3 min tutorial.

Still there? Great! Open your terminal and proceed to the next 4 steps...

作为开发人员,MacOSX是您最喜欢的操作系统吗?那么很有可能您已经在使用iCloud了。苹果公司推出了带有OSX10.10(约塞米蒂)的iCloud驱动器,允许您直接访问远程iCloud文件夹。最后,您可以直接在本地硬盘和iCloud之间来回移动文件。

iCloudDrive可以很容易地用作您的私有git存储库的远程存储。你不必再使用像Dropbox这样的第三方服务了。进一步阅读一个快速和简单的3分钟教程。

还在那吗?太棒了!打开你的终端,继续接下来的4个步骤.

Step 1

iCloud Drive is hidden in a verbose library folder accessible from the users home directory. We first create a symlink to simplify access to this directory via terminal:

iCloud驱动器隐藏在从用户主目录可访问的详细库文件夹中。我们首先创建一个符号链接,以简化通过终端对该目录的访问:

$ cd ~
$ ln -s Library/Mobile\ Documents/com~apple~CloudDocs/ icloud
$ cd icloud

Now we can simply cd into ~/icloud. All changes to this directory will automatically be synchronized with your iCloud account.

现在,我们可以简单地    cd into ~/icloud.。对此目录的所有更改将自动与您的iCloud帐户同步。

Step 2

Next we create a bare git repository in iCloud Drive which later serves as remote origin for our project:

接下来,我们在iCloudDrive中创建一个干净的git存储库,该存储库后来用作我们的项目的远程源代码:

$ cd ~/icloud
$ mkdir git-repos && cd $_
$ git init --bare my-project.git

Step 3

We're ready to create the actual git project. I'm using ~/projects as the root directory for all my dev projects. You might change this to fit your needs.

First we create a new project directory and add two files .gitignore and README:

我们准备创建实实在在的git项目。我在所有开发项目的根目录中都使用了 ~/Projects。您可能会根据您的需要对此进行更改。

首先,我们创建了一个新的项目目录,并添加了两个文件,分别是.gitignore文件、README文件:

$ cd ~/projects
$ mkdir my-project && cd $_
$ echo ".DS_Store" > .gitignore
$ echo "My Awesome Project" > README

Next we initialize a git repository for this project and add the bare repository created in step 2:

接下来,我们初始化该项目的一个git存储库,并添加在步骤2中创建的初始化的储库:

$ git init
$ git add .
$ git commit -m "initial commit"
$ git remote add origin ~/icloud/git-repos/my-project.git
$ git push -u origin master

Step 4

Finally we verify that the git repository has been successfully uploaded by checking the web ui of iCloud Drive:

最后,我们通过检查iCloudDrive的Web UI来验证git存储库是否已成功上传:

$ open https://www.icloud.com/#iclouddrive

That's it. Now we can simply use commands like git fetchgit pull and git push origin :branch to work with the iCloud Drive git repository.

$ cd ~
$ ln -s Library/Mobile\ Documents/com~apple~CloudDocs/ icloud
$ cd icloud

猜你喜欢

转载自blog.csdn.net/yz18931904/article/details/82077496