用GIT通过U盘同步文件

在多个电脑之间的文件同步.

考虑过用github,不过有些文件太大了,网络又给力。

所以想到了用U盘,单纯用COPY的话,文件一多,用U盘也慢。

然后试着用GIT:

参考了以下两篇文章:

http://uxcode.info/2010/10/06/116/sync-by-git/comment-page-1/#comment-928

http://www.freeoz.org/space/index.php?action/viewspace/itemid/2746

按第一篇文章的方法不行,总是有错,按提示,在U盘端配置文件config 最后面加了下面这一句:

denyCurrentBranch = ignore   如果git init 时,加上 –bare,则不用加上这句.

Git Book

http://progit.org/book/

http://zhiwei.li/text/2010/07/git-push%E6%8B%92%E7%BB%9D%E6%9B%B4%E6%96%B0/

git push拒绝更新

git version 1.7.7.1.msysgit.0

测试目录
/git/client1
/git/server
/git/client2
/git/copy
/git/shared

git PUSH

cd /git/server
git init –shared  如果不加 –bare ,就要做以下修改:
edit config:
at [receive]
add: denyCurrentBranch = false

cd ../client1
git init
git add .
git commit -m “one”
git pull ../server master

cd ../server
git status
deleted: ………
所有的文件都不存在,已经删除.
根据: http://stackoverflow.com/questions/3761684/git-after-push-remote-repo-shows-files-as-deleted?answertab=votes#tab-top
git reset –hard        文件恢复.

cd ../client2
git pull ../server      不成功
git init
git ../server   OK
modify some file
git push ../server

cd ../server
git status
client2 改动过的文件都不存在,已经删除.
git reset –hard        文件恢复.

git CLONE

cd ../copy
git clone ../server
cd server
modify some file
git add .
git commit -m “some file”
git push

cd ../../server
git status
copy 改动过的文件都不存在,已经删除.
git reset –hard        文件恢复.

git PUSH SHARED
cd ../shared
git init –bare init –shared
cd ../server
git push ../shared –all
显示成功,但目录里面没有工作文件
git reset –hard       文件恢复.

最后想是这样用吧:

computer A  edit <—-pull—- U盘 更新到U盘

computer B   —pull—-> U盘  从U盘下载更新

computer B edit  <—–pull—-U盘 更新到U盘

 

 

 

This entry was posted in Program, 未分类 and tagged . Bookmark the permalink.

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>