zoukankan      html  css  js  c++  java
  • 项目代码管理工具Git的总结

      在项目的开发中,代码的同步管理很重要,团队的几个人可以通过免费的github管理自己的开源项目代码,高效方便。下面说说,开发中经常用到的git指令操作,基于github平台。

      0.配置提交者的账户和邮箱名

    git config --global user.name "Your Real Name"    //账户
    git config --global user.email you@email.address           //邮箱

      1本地创建仓库,然后同步到远程github中。

    $git init                    //初始化
    
    $git add .                  //把所有文件加入到索引
    (不想把所有文件加入,可以用gitignore或add 具体文件)
    
    $git commit              //提交到本地仓库,然后会填写更新日志
    ( 填写更新日志 -m ,如$git commit -m “my first vesion of ...”)
    
    $git remote add origin git@github.com:WadeLeng/hello-world.git  //增加到remote
    
    $git push origin master    //push到github上

    2把github上的项目clone到本地

    $git clone git@github.com:WadeLeng/hello-world.git
    
    假如本地已经存在了代码,而仓库里有更新,把更改的合并到本地的项目:
    
    $git fetch origin    //获取远程更新
    
    $git merge origin/master //把更新的内容合并到本地分支

    3更新项目-创建了新的文件

    $git add .                  //这样可以自动判断新加了哪些文件,或者手动加入文件名字
    
    $git commit              //提交到本地仓库,不加参数会提示,注意:^=Ctrl,按照提示来就好了~~~
    
    $git push origin master    //不是新创建的,不用再add 到remote上了

    4更新项目-没有创建新闻界,只是修改了文件内容

    $cd ~/hello-world
    
    $git commit -a          //记录删除或修改了哪些文件
    
    $git push origin master  //提交到github

    5上传时忽略一些文件

    $vim .gitignore    //把文件类型加入到.gitignore中,保存
    
    然后就可以git add . 能自动过滤这种文件

    6 撤销和删除

    $git reset  //撤销
    
    $git rm  * // 删除

    备注 常见异常的解决

    1.$ git remote add origin git@github.com:WadeLeng/hello-world.git

    错误提示:fatal: remote origin already exists.

    解决办法:$ git remote rm origin

    然后在执行:$ git remote add origin git@github.com:WadeLeng/hello-world.git 就不会报错误了

    2. $ git push origin master

    错误提示:error:failed to push som refs to

    解决办法:$ git pull origin master //先把远程服务器github上面的文件拉先来,再push 上去。

    必须保证本地中的代码是远程中最新的,否则无法提交,公司每天都会debase

    未完待续  分支的管理 , ssh加密 等等

    收藏:http://blog.csdn.net/djl4104804/article/details/50778717

  • 相关阅读:
    Atitit 图像处理30大经典算法attilax总结
    Atitit 图像清晰度 模糊度 检测 识别 评价算法 源码实现attilax总结
    Atitit  rgb yuv  hsv HSL 模式和 HSV(HSB) 图像色彩空间的区别
    Atitit  从 RGB 到 HSL 或 HSV 的转换
    Atitit 图像清晰度 模糊度 检测 识别 评价算法 原理
    Atitit 修改密码的功能流程设计 attilax总结
    atitit 点播系统 概览 v2 qb1.docx
    Atitit dsl exer v3 qb3 新特性
    atitit.TokenService v3 qb1  token服务模块的设计 新特性.docx
    Atitit 异常机制与异常处理的原理与概论
  • 原文地址:https://www.cnblogs.com/rongyux/p/5295686.html
Copyright © 2011-2022 走看看