GitのRemoteリポジトリをDropboxのフォルダ内に作成する
Gitのことでちょっと調べものしてたら見つけたので試してみました。
Dropboxのフォルダ内にRemoteリポジトリを作成することで、Dropbox自体をGitサーバに見立てちゃおうって感じらしいです。
まずは、Dropboxの中に"リポジトリ名.git"フォルダを作成します。
Owner@Win7x64 /d/Data/Dropbox/Non_Public/repo $ mkdir -p hoge/hoge.git ; cd hoge/hoge.git/
次に空のリポジトリを作成します。
これでRemoteリポジトリの設定は基本的に完了です。簡単すぎるw
Owner@Win7x64 /d/Data/Dropbox/Non_Public/repo/hoge/hoge.git $ git init --bare Initialized empty Git repository in d:/Data/Dropbox/Non_Public/repo/hoge/hoge.git/
今度はLocalのリポジトリの設定です。こっち側の環境でコードを書いていくようにします。
なお、ここで空っぽのリポジトリをcloneしたのでwarningが出ますが気にしません。
Owner@Win7x64 /d/Data/git $ mkdir hoge ; cd hoge/ Owner@Win7x64 /d/Data/git/hoge $ git clone /d/Data/Dropbox/Non_Public/repo/hoge/hoge.git Cloning into hoge... done. warning: You appear to have cloned an empty repository. Owner@Win7x64 /d/Data/git/hoge $ ls -l total 2 drwxr-xr-x 3 Owner Administ 0 Jul 8 01:16 hoge Owner@Win7x64 /d/Data/git/hoge $ cd hoge/ Owner@Win7x64 /d/Data/git/hoge/hoge (master) $ la total 2 drwxr-xr-x 6 Owner Administ 4096 Jul 8 01:16 .git
".git"フォルダがcloneされてきていることを確認したら、お試しCommitをします。
Owner@Win7x64 /d/Data/git/hoge/hoge (master) $ echo "aaaaa" > aaa.txt Owner@Win7x64 /d/Data/git/hoge/hoge (master) $ la total 3 drwxr-xr-x 6 Owner Administ 4096 Jul 8 01:16 .git -rw-r--r-- 1 Owner Administ 6 Jul 8 01:19 aaa.txt Owner@Win7x64 /d/Data/git/hoge/hoge (master) $ git commit -a -m "Initial commit" [master (root-commit) 1f325ba] Initial commit 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 aaa.txt
これでLocalリポジトリで今回のCommitがStagingされた状態になりました。
次はRemoteリポジトリ(Dropbox側)にPushします。
まずは、Push URLが設定されているかどうか確認します。
Owner@Win7x64 /d/Data/git/hoge/hoge (master) $ git remote show origin * remote origin Fetch URL: d:/Data/Dropbox/Non_Public/repo/hoge/hoge.git Push URL: d:/Data/Dropbox/Non_Public/repo/hoge/hoge.git HEAD branch: (unknown) Local branch configured for 'git pull': master merges with remote master
設定されているようなので、"git push origin master"でPushができますね。
Owner@Win7x64 /d/Data/git/hoge/hoge (master) $ git push origin master Counting objects: 3, done. Writing objects: 100% (3/3), 221 bytes, done. Total 3 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. To d:/Data/Dropbox/Non_Public/repo/hoge/hoge.git * [new branch] master -> master
もしPush URLが設定されてなかったら、以下のようにして設定しておきます。
Owner@Win7x64 /d/Data/git/hoge/hoge (master) $ git remote add origin d:/Data/Dropbox/Non_Public/repo/hoge/hoge.git
または、直接RemoteリポジトリのURLを入力してPushします。
Owner@Win7x64 /d/Data/git/hoge/hoge (master) $ git push d:/Data/Dropbox/Non_Public/repo/hoge/hoge.git master
Gitでコード管理するためにサーバを立てたり借りたりしなくていいってのはかなり便利ですね。
#しかしこの事実3ヶ月前に気付いておきたかった。。(>_<)