zoukankan      html  css  js  c++  java
  • git到GitHub的操作和遇到的一些问题

    一、新建完项目后执行git

    git status      //查看状态,任何时候都可以用

      1. git init       //初始化文件夹,并创建.git本地仓库(.git默认隐藏)

       

      2. git add .      //把文件夹的内容添加到本地仓库中    (. 为全部,可以添加指定文件或文件夹;例如git add test.txt)

       

      3. git commit -m "想要输入的内容"   //提交的备注

      

      4. git remote add origin 地址         //地址,为你的GitHub中的项目地址,关联项目地址

      

        4.1 第四步过程中有可能出现  

        

          fatal: remote origin already exists.      因为这个命令重复添加了

          解决办法:git remote rm origin  //删除这个origin之后继续第五步

      5. git push -u origin master      //推送到GitHub上

        

        5.1 git pushs失败

        

        失败代码:

          To https://github.com/Vokiinnn/Test.git
           ! [rejected]        master -> master (non-fast-forward)
          error: failed to push some refs to 'https://github.com/Vokiinnn/Scenic_evaluate.git'
          hint: Updates were rejected because the tip of your current branch is behind
          hint: its remote counterpart. Integrate the remote changes (e.g.
          hint: 'git pull ...') before pushing again.
          hint: See the 'Note about fast-forwards' in 'git push --help' for details.

          //这个的大意是更新失败,因为现在推送的分支已经存在(两条master分支?)

        解决办法git pull origin master --allow-unrelated-histories      //强制合并

        

           输入已上命令后,会出现一个文本文档,保存后退出,再次push 成功

    二、更新数据后再次提交

      1. cd到需要提交的目录中,右键打开git bash

      2. git add 需要提交的文件名或文件目录

      3. git commit -m "提交的备注"(第三项可选可不选)

      4. git push origin master (master为主分支,如需提交到其他分支,请在第一步完成后执行切换分支操作,然后继续下面步骤)

     

  • 相关阅读:
    HDU-3790 最短路径问题(双重权值)
    Graph (floyd)
    POJ-3259 Wormholes(判断负环、模板)
    HDU-1317 XYZZY
    HDU-1548 A strange lift(单源最短路 或 BFS)
    最小生成树(模板 prim)
    【面试】386- JavaScript 面试 20 个核心考点
    【Koa】385- koa框架的快速入门与使用
    【小程序】384- 如何一人五天开发完复杂小程序(前端必看)
    【React】383- React Fiber:深入理解 React reconciliation 算法
  • 原文地址:https://www.cnblogs.com/vokiinnn/p/11604802.html
Copyright © 2011-2022 走看看