Chinaunix首页 | 论坛 | 博客
  • 博客访问: 810080
  • 博文数量: 222
  • 博客积分: 4341
  • 博客等级: 上校
  • 技术积分: 2155
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-16 13:50
个人简介

...

文章分类

全部博文(222)

文章存档

2019年(1)

2016年(9)

2015年(7)

2014年(14)

2013年(11)

2012年(10)

2011年(6)

2010年(25)

2009年(37)

2008年(21)

2007年(81)

我的朋友

分类: LINUX

2009-12-22 14:30:08

1. 注意事项
 由 project/.git/config 可知:
 origin(remote) 是 Repository 的版本
 master(branch) 是 local 端, 正在修改的版本
2. 安装配置
 sudo apt-get install git-core
 git config --global user.name "etony"
 git config --global user.email
 git config -l  #检查已有的配置信息

3. 取得或建立一个版本库
 git clone git://somehost/someone/git.git
 git clone
 git clone ssh://user@somehost/someone/git.git
 git init (当前目录)
4. 日常操作
 git add
 git diff
 git commit, git commit -a , git commit -m '注解' -a
 git commit -a -v  # -v 可以看到哪些內容有被更改,
 git rm filename
 git mv filename new-filename
 
5. 查看状态
 git status
 
6. 比较差异
 git diff   #比较当前的工作目录和版本库数据库中的差异
 git diff --stat  #差异统计
 
7. 同步
 git pull #与服务器同步,可用:来指定源的分支和本地分支,是git fetch和git merge命令的一个组合
 git fetch #只是将远端的数据拉到本地仓库,并不自动合并到当前工作分支 
 git push #同步到服务器
 git push origin master
 
8. 回溯
 git reset --hard,  git reset --hard filename #取消暂存的文件, 即status中列出的修改信息,撤销最近的n次commits,就用git-reset HEAD~,例如HEAD~2 
 git checkout -- filename
 git reset
9. 远程维护
 git remote -v #显示远程地址
 git remote show [remote-name] #查看远程仓库信息
 git remote add [shortname] [url]  #添加远程仓库
 git remote rename 1 2 #远程仓库的重命名
 git remote rm   #远程仓库的删除
10. 分支
 git branch  #新建分支
 git checkout  #切换分支
 git merge   #合并到当前分支
 git branch #当前所有分支的清单
 git branch -v #看各个分支最后一次 commit 信息
11. 查看提交历史
 git log
 git show  #查看详细信息
 
 
 
 http://blog.chinaunix.net/u/17564/showart_1011997.html
 
 
阅读(1107) | 评论(0) | 转发(0) |
0

上一篇:命令行查询

下一篇:Version Control with Git

给主人留下些什么吧!~~