zoukankan      html  css  js  c++  java
  • windows上传文件到github的方法

    一、创建github的账号:

    https://github.com/

    二、安装git:

    链接:https://pan.baidu.com/s/1BucksB0HscAxEd7YpjgekA

    提取码:0aes

    可以通过官网下载,不过官网下载很慢。下载后逐步安装Git Bash Here,基本都是下一步即可。

    三、上传

    1.右击有一个命令Git Bash Here,出现git的命令行:

    2.输入"mkdir 文件夹名**" ,创建一个文件夹。

    3.输入"cd 文件夹名",进入该文件夹。

    4.通过"git init"命令把这个文件夹变成可管理的仓库。

    这时会发现该文件夹内会出现一个 ".git"的文件夹,如果看不到,可能是隐藏了,通过"查看"属性,将其显示即可。

    5.下一步,将你想要上传的项目copy到这个文件夹内,然后使用"git add ."这个命令将项目添加到仓库,(注意add 和 .之前 有空格),可以用"git status"命令查看当前的状态,

    6.然后再使用"git commit -m "第一次提交""命令将项目提交到仓库(注意git commit的时候后面要加 "-m",否则会报错,之前我一直没加,一直报错,加了之后就ok了)。

    本地仓库已经完成,由于本地仓库和远程的github是通过Https或者是SSH来连接的,所以要设置一下远程的仓库。

    7.创建ssh key. 使用命令" ssh-keygen -t rsa -C "邮箱账号" ".一路回车即可,然后可以到C盘--》用户下有一个.ssh目录下有以下2个文件

    8.然后登录你的github,找到下面settings:

    9.然后点开它:

       

    10.创建一个ssh Key,点击New SSh key.

    其中Title可以随便写一个,Key里的值将你刚才.ssh里的id_rsa.pub中的内容全部复制到这即可,最后点击Add SSh key。

    11.然后在创建一个仓库,

       

    这时候远程的仓库创建好了,可以进行连接并上传了,回到本地的命令行中,

    12.先连接"git remote add origin ******",****是以下的网址,将以下的网址copy,

    13.最后使用 "git push -u origin master"

    至此,就完成了项目的上传,(中间可能会输入你的github的用户名和密码),你可以到你的github上刷新一下。

    另外,如果在github上创建了仓库的时候,你勾选了如果你勾选了Initialize this repository with a README,则会报一个错

    failed to push some refs to https://github.com/guyibang/TEST2.git

    你可以使用这个命令"git pull --rebase origin master",然后再使用push的命令。

       

    简单来说就是以下几个命令:

    1.在本地创建一个文件夹mkdir Hello,进入到该文件夹cd Hello,然后初始化git init

    2.把项目复制进来,通过 git add . 添加 

    3.使用 git commit -m "注释"提交。

    4.在github上设置ssh,再进行连接git remote add origin https://github.com/guyibang/TEST2.git

    5.最后能过git push -u origin master。

     

    Git常见错误与操作:error: src ref spec master does not match any解决办法,再来一遍下面的:

    git add .

    git config --global user.email "你的github注册的邮箱"

    git commit -m "EP_GR"

    git push origin master

       

       

    参考文档:

    https://blog.csdn.net/Lucky_LXG/article/details/77849212

    https://blog.csdn.net/zamamiro/article/details/70172900

    https://blog.csdn.net/s164828378/article/details/52425208

  • 相关阅读:
    Two Sum II
    Subarray Sum
    Intersection of Two Arrays
    Reorder List
    Convert Sorted List to Binary Search Tree
    Remove Duplicates from Sorted List II
    Partition List
    Linked List Cycle II
    Sort List
    struts2结果跳转和参数获取
  • 原文地址:https://www.cnblogs.com/yifanrensheng/p/11969852.html
Copyright © 2011-2022 走看看