zoukankan      html  css  js  c++  java
  • GitHub练习——如何将本地已有项目添加到github

    刚开始开始接触,搞点简单的,看看是怎么把项目传上去,总结一下,大概是这些步骤:

    1. 创建本地仓库
    2. 将本地仓库变成git可管理的仓库:git init
    3. 把项目文件添加到缓存区:项目文件添加到已有的仓库,然后git add .(. 表示当前目前所有文件,也可以指定文件)。
    4. 提交项目:git commit -m "说明"
    5. github创建git仓库
    6. 关联本地仓库:git remote add origin git@github.com:wpbxin/hello-world.git。(在此之前需要可以使用SSH进行验证配置,可以自行度娘或谷歌)
    7. 推送:git push -u origin master,由于新建的远程仓库是空的,所以要加上-u这个参数,等远程仓库里面有了内容之后,就不需要使用-u。

    如下是github上的截图,也描述得比较清楚,上述的步骤基本上可以看到

     1 #…or create a new repository on the command line
     2 echo "# hello-world" >> README.md
     3 git init
     4 git add README.md
     5 git commit -m "first commit"
     6 git remote add origin git@github.com:wpbxin/hello-world.git
     7 git push -u origin master
     8 
     9 # …or push an existing repository from the command line
    10 git remote add origin git@github.com:wpbxin/hello-world.git
    11 git push -u origin master
    12 
    13 #…or import code from another repository
    14 You can initialize this repository with code from a Subversion, Mercurial, or TFS project.

    以下是没有可以提交的文件时,使用git push报的错:

    1 error: src refspec master does not match any.
    2 error: failed to push some refs to 'git@github.com:xxx/xxcxxxxx.git'
  • 相关阅读:
    javascript实现动态侧边栏
    javascript实现图片滚动
    C语言-----野指针
    守护进程daemon.c
    UDP网络程序设计
    TCP网络程序设计
    网络编程模型
    fork和vfork
    网络协议分析
    多线程同步
  • 原文地址:https://www.cnblogs.com/wpbxin/p/8874447.html
Copyright © 2011-2022 走看看