zoukankan      html  css  js  c++  java
  • git

    【记录】GIT学习(1)

     
    在GITHUB上的文件 https://github.com/jun-lu/jun/blob/master/gitNotes.txt
    GIT 学习笔记
    
    集中化的版本控制系统  CVCS
    分布式版本控制系统  DVCS
    
    Git 基础要点 http://progit.org/book/zh/ch1-3.html
     1:直接快照,而非比较差异
     2:近乎所有操作都可本地执行
     3:时刻保持数据完整性 (Git 使用 SHA-1 算法计算数据的校验 ,40 个十六进制字符(0-9 及 a-f)组成)
     4:多数操作仅添加数据
     5:三种状态(已提交(committed),已修改(modified)和已暂存(staged))
     
    GIT安装  http://progit.org/book/zh/ch1-4.html
    
    
    配置GIT http://progit.org/book/zh/ch1-5.html
      $ git config --global user.name "John Doe"
      $ git config --global user.email johndoe@example.com
      
      查看配置
      
      git config --list
      
      
      
     
    GIT 基础
    	初始化仓库
    	$ git init
    	$ git add *.c
    	$ git add README
    	$ git commit -m 'initial project version'
    	
    	从现有仓库克隆
    	$ git clone git://github.com/schacon/grit.git
    	
    	仓库状态
    	$ git status
    	
    	跟踪新文件
    	$ git add fileName
    	
    	忽略某些文件
    	$ cat .gitignore
    	*.[oa] //忽略以 .o 或 .a 结尾的文件
    	*~ //忽略所有以波浪符(~)结尾的文件
    	
    	查看已暂存和未暂存的更新
    	$ git diff
    	$ git diff --cached  //已经暂存起来的文件和上次提交时的快照之间的差异
    	
    	提交更新
    	$ git commit -m "message" // 简单的提交方式
    	$ git commit -a -m "message" // 跳过add 步骤 把已经跟踪的文件全部提交
    	
    	移除文件
    	$git rm fileName
    	$ git rm --cached readme.txt //移除跟踪但不删除文件
    	
    	移动文件
    	$ git mv file_from file_to
    	
    	日志
    	$ git log
    	$ git log –p -2 // -p 提交内容的差异  -2最近两次
    	$ git log --stat//显示简要的增改行数统计
    	
    	修改最后一次提交
    	$ git commit --amend
    	//---第2次提交修改了第一次提交
    	$ git commit -m 'initial commit'
    	$ git add forgotten_file
    	$ git commit --amend 
    	
    	取消已经暂存的文件
    	$ git reset HEAD fileName
    	
    	取消对文件的修改(回退到以前未修改的状态) //很有用 也很危险
        	$ git checkout -- fileName
    
    远程仓库的使用
    
        查看当前的远程库
    	$ git remote -v // -v 列出远程地址
    	
    	添加远程仓库
    	$ git remote add Name git://github.com/paulboone/ticgit.git
    	
    	从远程仓库抓取数据
    	$ git fetch [remote-name]
    	$ git pull// 合并远程的全部分支到本地(不确定)
    	
    	推送数据到远程仓库
    	$ git push origin master //推送 origin 到 master
    	
    	查看远程仓库信息
    	$ git remote show origin
    	
    	远程仓库的删除和重命名
    	$ git remote rename pb paul// pb 改成 paul  分支对应前缀也会发生变化
    	
    	$ git remote rm paul// 貌似删除
    
    	
    打标签 http://progit.org/book/zh/ch2-6.html
    	列显已有的标签
    	$ git tag
    	$ git tag -l 'v1.4.2.*'//搜索标签
    	
    	新建标签
    	$ git tag -a v1.4 -m 'my version 1.4' //新建v1.4标签 消息是 my version 1.4
    	
    	分享标签
    	$ git push origin [tagname] //提交 一个标签
    	$ git push origin --tags // 推送所有本地标签
            
            删除
    	$ git tag -d [tagname] //删除标签
    	$ git push origin :refs/tags/tagname //删除远程标签
    	
    
    技巧和窍门
    	提示 // 敲两次tab
    	Git 命令别名
    	$ git config --global alias.co checkout // git co 代替了 git checkout
    
    
    分支
    
        	创建分支
    	$ git branch testing // 创建testing
    	$ git checkout testing// 切换到testing
    	$ git checkout -b iss53 //创建并切换到iss53
    	$ git merge hotfix //把hotfix 分支合并到当前分支
    	
    	查看分支
    	$ git branch -v//最后一次commit信息
            $ git branch --merged | --no-merged//筛选出你已经(或尚未)与当前分支合并的分支
    
            删除
    	$ git branch -D testing
    
    	推送
    	$ git push origin serverfix//把当前推送到 serverfix分支
    	
    	更新同步
    	$ git fetch
    	
    	删除远程分支
    	git push origin :branchname
    	
    	git branch  –r //查看所有分支信息
    	
    	//获取远端分支
    	$ git checkout -b sf origin/serverfix
    	
    
    服务器上的GIT
    		       ---http://progit.org/book/zh/ch4-3.html	
    	生成 SSH 公钥  ---http://github.com/guides/providing-your-ssh-key。
    	$ cd ~/.ssh //公钥的位置
    	$ ls
    	authorized_keys2  id_dsa       known_hosts
    	config            id_dsa.pub
    	
    	$ ssh-keygen //如果上面看不到公钥  可以用次来创建 会要求输入存放位置 和密码
    
    
    储藏
    	$ git status //储藏
    	$ git stash list//储藏列表
    	$ git stash apply//应用储藏
    
    参考资料
       http://zh.wikipedia.org/wiki/Git
       http://progit.org/book/zh/
    	
    	
    
    
     
     
     
    0
    0
     
    (请您对文章做出评价)
     
    « 博主上一篇:【动态】简单的JS动态加载单体
    » 博主下一篇:【分享】关于a标签的4个伪类
    posted @ 2011-07-05 12:04 Jun.lu 阅读(699) 评论(1) 编辑 收藏

     

  • 相关阅读:
    386. Lexicographical Numbers 输出1到n之间按lexico排列的数字序列
    287. Find the Duplicate Number 找出数组中的重复数字
    165. Compare Version Numbers比较版本号的大小
    java之spring mvc之文件上传
    java之spring mvc之Restful风格开发及相关的配置
    java之spring mvc之页面跳转
    java之spring mvc之数据处理
    java之spring mvc之Controller配置的几种方式
    java之spring mvc之helloworld
    java之spring mvc之初始spring mvc
  • 原文地址:https://www.cnblogs.com/DamonTang/p/2968479.html
Copyright © 2011-2022 走看看