船過水無痕

Java | Web | Architecture
posts - 12, comments - 0, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

Git

Posted on 2010-02-01 23:10 zdxue 阅读(337) 评论(0)  编辑  收藏 所属分类: Software Engineering
1.建库
    git init/git clone git://host/gitname.git

2.更新到库
    git add <file/regex>
    git commit -m <message>
    git commit -a -m <message>

    git status/diff
    git diff --cached/--staged
    .gitignore配置文件,忽略指定跟踪文件

    git rm -f <file/regex>
    git mv <file1> <file2>

3.查看提交历史
    git log [options] ...

4.撤销操作
    git commit --amend
    git reset HEAD <file>
    git checkout --<file>

5.远程仓库
    查看:
        git remote -v
        SSH URL链接(git@host:port/gritname.git),也只有这个仓库能推送数据上去
    添加:
        git remote add demo git://host/gitname.git
    从远程仓库抓取数据:
        git fetch [remote-name]  fetch命令只是将远端的数据拉到本地仓库,并不自动合并到当前工作分支,只有当你确实准备好了,才能手工合并。
        git pull        如果设置了某个分支用于跟踪某个远端仓库的分支
    推送数据到远程仓库:
        git push [remote-name] [branch-name]   例:$ git push origin master
        只有在所克隆的服务器上有写权限,或者同一时刻没有其他人在推数据,这条命令才会如期完成任务。
        如果在你推数据前,已经有其他人推送了若干更新,那你的推送操作就会被驳回。
        你必须先把他们的更新抓取到本地,并到自己的项目中,然后才可以再次推送。有关推送数据到远程仓库的详细内容见第三章。

6.查看远程仓库信息
    git remote show [remote-name] 查看某个远程仓库的详细信息

7.远程仓库的删除和重命名
    git remote rename <name1> <name2>
    git remote rm <projectName>
   

只有注册用户登录后才能发表评论。


网站导航: