使用git的时候难免会用到remote tracking,下面简要记录一下在使用git remote时的一些技巧
(1)add
$git remote add origin https://github.com/ask/celery.git
注:暂以celery的git作为示例,celery是一个挺不错的Distributed Task Queue,有很多值得学习的地方,在此也顺便推广一下celery
(2) show remote
$git remote show origin
通过$git remote show origin来得到remote中的所有branch列表
(3)fetch
$git fetch --depth=1 origin master
通过depth来指定获取最近的多少个commit,可以通过这一参数来根据需要限定获取的commit个数
(4)create branch
$git branch master
(5)merge
$git checkout master
$git merge FETCH_HEAD
(6)diff HEAD FETCH_HEAD
$git diff HEAD FETCH_HEAD,检测当前HEAD和FETCH_HEAD之间的区别,如果有区别的话,可以认为是有更新或者变动,如果想通过git来做autoupdate的话,可以根据diff的结果,决定是否重新fetch
(7)create empty empty
$git symbolic-ref HEAD refs/heads/newbranch
$rm .git/index
$git clean -fdx
$<do work>
git add your files
$git commit -m 'Initial commit'
本文简要介绍了在使用Git远程仓库时的一些实用技巧,包括如何添加远程仓库、查看远程分支、获取特定版本的提交历史、创建本地分支、合并远程分支、检测与更新等关键步骤。同时推广了分布式任务队列Celery,展示了Git在项目管理和版本控制中的强大功能。
2万+

被折叠的 条评论
为什么被折叠?



