找回密码
 立即注册

QQ登录

只需一步,快速开始

帖子
查看: 3658|回复: 0
收起左侧

实例GIT的使用

[复制链接]
ID:51773 发表于 2013-8-11 23:49 | 显示全部楼层 |阅读模式
                                                                                                以最近编译android中使用到的例子记录一下GIT的使用

1,开始git服务
git daemon --verbose --enable=receive-pack --export-all --base-path=/opt/git-srv /opt/git-srv
其中--enable=receive-pack为允许提交到此开放的仓库中

2,完整克隆远程仓库到本地,包括所有LOG和所有分支
git clone --bare URL
如:
git clone --bare git://127.0.0.1/android/tools/repo.git

3,克隆某分支(默认为主分)到本地并checkout
git clone -b BRANCH URL
如:
取得主分支
git clone git://127.0.0.1/android-x86/platform/manifest.git
取得android-x86-1.6的分支
git clone -b android-x86-1.6 git://127.0.0.1/android-x86/platform/manifest.git

4,查看分支
查看当前工作所在分支
$ git branch
* master

查看所有库的分支,包括本地与远程
$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/android-x86-1.6
  remotes/origin/android-x86-v0.9
  remotes/origin/donut-x86
  remotes/origin/master
  remotes/origin/mirror

查看远程库的分支
$ git branch -r
  origin/HEAD -> origin/master
  origin/android-x86-1.6
  origin/android-x86-v0.9
  origin/donut-x86
  origin/master
  origin/mirror
­
5,从当前现有分支中派生出新分支并工作到新分支中­
git checkout -b NEW_BRANCH OLD_BRANCH­
如:­
从远程仓库的android-x86-1.6分支建立新分支android-x86-1.6-local­
$ git checkout -b android-x86-1.6-local origin/android-x86-1.6­
Branch android-x86-1.6-local set up to track remote branch android-x86-1.6 from origin.­
Switched to a new branch 'android-x86-1.6-local'­
­
6,切换工作分支­
git checkout BRANCH­
如:­
切到主分支­
$ git checkout master­
Switched to branch 'master'­
­
7,在当前工作分支中派生出新分支­
git branch NEW_BRANCH­
如:­
git checkout android-x86-1.6-new­
­
8,列出远程库­
$ git remote -v­
origin  git://127.0.0.1/android-x86/platform/manifest.git (fetch)­
origin  git://127.0.0.1/android-x86/platform/manifest.git (push)­
­
9,删除/添加远程库­
git remote rm NAME­
git remote add [--mirror] NAME URL­
如:­
删除­
git remote rm origin­
添加­
git remote add --mirror git://git.android-x86.org/platform/manifest.git­
­
10,同步远程库的变动到本地­
git remote update­
注:­
还不明白此命令与git fetch和git pull三者间的区别与关系­
­
11,配置­
git config­
如,使用vi来编辑提交信息:­
git config core.editor vi­
­
12,本地库的改动同步到远程库­
git push [--all]­
­
13,其实一些常用的命令­
git add  //添加文件/目录­
git rm   //删除文件/目录­
git diff //对比­
git log  //查看日志­
git show­
git commit -a [-m "xxxx"] //提交­
                                                                                            


回复

举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表