• Git基本操作


    1.创建新项目上传

    cd parent_dir //进入项目父目录
    mkdir gitDemo  //创建项目目录 gitDemo
    cd gitDemo   //进入项目目录
    git init  //初始化空的 git 仓库
    touch README.md   
    git add README.md //这两行添加简单的 README.md 文件
    git commit -m "first commit" //提交时附加的信息
    git remote add origin https://coding.net/codingTutorial/gitDemo.git  //添加一个名为 origin 的远端( url 为 git 地址)
    git push -u origin master //将该目录下的文件推送到远端(origin)上的 "master" 分支

    可能会遇到的问题

    a.如果是首次使用,会提示你先设置好用户名和邮箱,可以在 cmd 中输入:

      git config --global user.email "you@example.com"
      git config --global user.name "Your Name"

    b.git push失败,出现以下提示

     ! [rejected]        master -> master (fetch first)
    error: failed to push some refs to 'https://github.com/dummymare/Hello-World.git'
    hint: Updates were rejected because the remote contains work that you do
    hint: not have locally. This is usually caused by another repository pushing
    hint: to the same ref. You may want to first integrate the remote changes
    hint: (e.g., 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.

    解决方法:

    原因:本地版本和主干上的有差异先pull远端的版本,解决了冲突才能push

      git pull -u origin master

    然后再

     git push -u origin master

    做个小推广:程序员经常久坐,颈椎毛病比较多,特别推荐ventry颈椎保健枕

  • 相关阅读:
    ztree学习---将默认勾选的展开
    CentOS之RPM
    CentOS之文档的压缩与打包
    CentOS之Vim
    CentOS用户和用户组管理
    Linux CentOS更改文件的权限
    CentOS的文件属性:命令 ls -l
    CentOS命令
    Java解析excel
    easyUI的combotree的树的懒加载。
  • 原文地址:https://www.cnblogs.com/longzhongren/p/4307194.html
Copyright © 2020-2023  润新知