zoukankan      html  css  js  c++  java
  • git 学习

    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 log --author=wanqi
    配置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/
  • 相关阅读:
    linux php安装ODBC扩展
    linux wget变成000权限
    linux tomcat启动报错:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
    字符串的操作, 日期格式, 数据转换, 模糊查询
    Oracle控制结构
    创建角色,用户,视图,索引,分析计划
    Oracle用触发器解决修改主表A主键值,从表的外键值也会跟着改变的问题
    行为科学统计第17章--回归
    行为科学统计第13-15章
    行为科学统计第12章
  • 原文地址:https://www.cnblogs.com/wanqieddy/p/2148908.html
Copyright © 2011-2022 走看看