用 Dropbox 做私有 Git 服务器

1. 安装GitHubSetup.exe for windows

2. 安装Dropbox 1.6.17.exe for windows


3.  D:\ 根目录下有自己的source目录

-D:\MySourceCode

 -README.txt

 -stdafx.cpp

 -include

  -stdafx.h

用 Dropbox 做私有 Git 服务器_第1张图片


3. 打开GitShell, 安装完GitHub windows客户端会生成该快捷方式

用 Dropbox 做私有 Git 服务器_第2张图片


4. gitshell 命令行界面

命令行默认路径为GitHub GUI客户端中设置的默认"default storage directory", 如下图

用 Dropbox 做私有 Git 服务器_第3张图片


5. 

cd ..

cd .\MySourceCode

用 Dropbox 做私有 Git 服务器_第4张图片


命令行结果,多出.git文件夹

用 Dropbox 做私有 Git 服务器_第5张图片


6. 提交原有的code等文件到git 本地Repo

git add .
git commit -m "commit orignal source code."

用 Dropbox 做私有 Git 服务器_第6张图片


7. 生成一个不带source code的Git仓库

cd ..
git clone --bare MySourceCode MySourceCodet.git


7. 生成一个不带source code的Git仓库

 

cd .. 
git clone --bare MySourceCode MySourceCodet.git
用 Dropbox 做私有 Git 服务器_第7张图片

用 Dropbox 做私有 Git 服务器_第8张图片


8. 把MySourceCodet.git移动到Dropbox同步目录D:\Dropbox(一开始直接把MySourceCodet.git创建在同步目录也可以)

用 Dropbox 做私有 Git 服务器_第9张图片


至此,dropbox的作为私有的git服务器功能已经完成

下面做实验
1. E盘下创建test1目录
用 Dropbox 做私有 Git 服务器_第10张图片


2. gitshell 
cd E:\test1
git clone file:///D:\Dropbox\MySourceCodet.git
用 Dropbox 做私有 Git 服务器_第11张图片

E:\test1目录下clone了MySourceCode的代码
用 Dropbox 做私有 Git 服务器_第12张图片

3. 通过notepad编辑E:\test1\MysourceCodet下的代码

4. GitShell
cd .\MySourceCodet
git pull //把远端Repo上的文件拉下来
git status //查看mofify状态
git add . //把所有文件添加进需要commit的列表
git commit -m "msg: commit updated files"
此时已经把user的修改提交到本地的Repo
用 Dropbox 做私有 Git 服务器_第13张图片


5. 把本地repo的改动push到远端Repo
用 Dropbox 做私有 Git 服务器_第14张图片

6. 在E:盘下创建E:\test2

7. gitshell
cd ..
cd ..
cd test2
git clone file:///D:\Dropbox\MySourceCodet.git
用 Dropbox 做私有 Git 服务器_第15张图片

8. 进入test2查看,是test1最新commit到远端服务器的代码
cd MySourceCode
git log
用 Dropbox 做私有 Git 服务器_第16张图片

遗留问题:
git remote add origin  file://xxxx/MySourcecode .git这个命令用来做什么,添加远程仓库?具体什么含义

参考文献
1.  方便而又强大:本地 Git 操作完全指南
2.  2.5 Git 基础 - 远程仓库的使用
3.  Git教學:Git的遠端操作及利用Dropbox建立Server進行協同開發(Windows)
4.  Git教學:初學者使用心得分享(Windows)
5.  用 Dropbox 做私有 Git 服务器



你可能感兴趣的:(用 Dropbox 做私有 Git 服务器)