zoukankan      html  css  js  c++  java
  • git的使用

      1.用git Bash 命令

      2.绑定用户

    $ git config --global user.name "xiaoyucheng921"
    $ git config --global user.email "1053961679@qq.com"

    3.生成ssh key
    首先检查是否已生成密钥cd ~/.ssh,如果返回的ls有3个文件,则密钥已经生成。
    如果没有密钥,则通过
    $ ssh-keygen -t rsa -C "1053961679@qq.com"生成
    生成过程中一路按3次回车键 C:Users.ssh
    4为github账号配置ssh key
    登录github官网 点击头像———>settings--->SSH and GPG keys--->SSH keys--->key 将id_rsa.pub文件中key粘贴到此,最后Add key生成密钥
    第一次需要以上步骤,以后可直接跳过
    5
    上传本地项目到github
    1.cd d:XXXX进入到项目文件夹XXXX
    2.执行指令:git init 初始化成功后项目里多了一个隐藏文件夹.git
    3.执行指令:git add .
    将所有文件添加到仓库
    4.执行指令:git commit -m "提交文件" 双引号内是提交注释。
    6
    关联github仓库

    2.执行指令:git remote add origin https://github.com/xiaoyucheng921/news.git 这个地址是github创建仓库时产生的
    3.执行指令:git push -u origin master



    ----------------------------------git的基本使用------------------------------------------


    第一步:建立git仓库

    
    

    git init

    
    

    第二步:生成“.gitignore”文件,配置不上传的文件及文件夹

    
    

    touch .gitignore

    
    

    第三步:将项目的所有文件添加到仓库中

    
    

    git add .

    
    

    第四步:将add的文件commit到仓库

    
    

    git commit -m "注释语句"

    
    

    第五步:将本地的仓库关联到github上

    
    

    git remote add origin https://github.com/xiaoyucheng921/test.git

    
    

    第六步:查看本地代码状态
    git status

    
    

    第七步:上传代码到github远程仓库

    
    

    git push -u origin master

    --------------------“.gitignore”文件的匹配规则-------------------------------
    # 此为注释 – 将被 Git 忽略

    
    

    *.a # 忽略所有 .a 结尾的文件
    !lib.a # 但 lib.a 除外
    /TODO # 仅仅忽略项目根目录下的 TODO 文件,不包括 subdir/TODO
    build/ # 忽略 build/ 目录下的所有文件
    doc/*.txt # 会忽略 doc/notes.txt 但不包括 doc/server/arch.txt

     
    
    

    ----------------------使用git出现的问题----------------------
    1、windows使用git时出现:warning: LF will be replaced by CRLF
    windows中的换行符为 CRLF, 而在linux下的换行符为LF,所以在执行add .
    时出现提示,解决办法:
    $ rm -rf .git // 删除.git
    $ git config --global core.autocrlf false //禁用自动转换

    
    

    然后重新执行:
    $ git init
    $ git add .

    
    


    2、src refspec master does not match any

    
    

    引起该错误的原因是,目录中没有文件,空目录是不能提交上去的

    
    

    解决方法
    touch README

    
    

    git add README
    git commit -m 'first commit'
    git push origin master









     
  • 相关阅读:
    桟错误分析方法
    gstreamer调试命令
    sqlite的事务和锁,很透彻的讲解 【转】
    严重: Exception starting filter struts2 java.lang.NullPointerException (转载)
    eclipse 快捷键
    POJ 1099 Square Ice
    HDU 1013 Digital Roots
    HDU 1087 Super Jumping! Jumping! Jumping!(动态规划)
    HDU 1159 Common Subsequence
    HDU 1069 Monkey and Banana(动态规划)
  • 原文地址:https://www.cnblogs.com/xyc211/p/7102824.html
Copyright © 2011-2022 走看看