zoukankan      html  css  js  c++  java
  • git——同步本地文件到github上

    参考教程:

    1.https://blog.csdn.net/weixin_37769855/article/details/99439904

    2.https://www.liaoxuefeng.com/wiki/896043488029600/896067074338496

    3.https://www.cnblogs.com/pythoner6833/p/9051523.html

    一、首先,注册github(github.com),下载git bash到本地

    二、在本地(windows桌面鼠标右键即可)git bash上配置本地个人用户名和邮箱,配置ssh

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

    配置ssh(百度:配置github ssh)

    三、到github上创建一个new repository(仓库)

     随便取名比如Test(可以把README.md勾选上)

    四、创建本地仓库

    windows鼠标右键新建一个文件夹(最好不带中文名,避免出错),右键该文件夹进入git bash

    或者,直接在git bash终端下,

    mkdir git_test

    cd git_test

    初始化命令,git init,用来创建一个.git文件

    五、建立远程连接

    git remote add origin git@github.com:beathahahaha/Test.git

    最后这个字段是自己github上新建立的这个Test 仓库的SSH!不要选成HTTPS了!之后会遇到坑

    正确示范:

    错误示范:(以https开头)

    其他之后有用的指令:

    git remote -v  (查看当前连接情况)

    git remote remove origin(删除当前origin这个连接)

    git remote add origin 地址名(添加名为orgin的连接)

    git pull orgin master (将github上该仓库的主分支master同步到本地,pull:拉到本地)

    git pull origin master --allow-unrelated-histories(若出现pull时说无相关历史报错,则用该命令)

    git push -u origin master (将本地文件提交到github上,注意是origin,有些博客写的orgin,坑!)

    六、本地与远端的同步

    本地文件夹里可以新建一些文件,比如写一个hello.txt(vim hello.txt)

    一定要先执行git add . (提交全部文件)或者 git add 具体文件名(如git add hello.txt)

    再git commit -m “some messages”  (真正的提交指令,-m是留言功能,对比add,只是一个暂存区的作用)

    此时,还是不要直接git push -u origin master,会报错,类似如下:

    所以先git pull orgin master 或者 git pull origin master --allow-unrelated-histories

    再 git push -u origin master,成功

     

    刷新github仓库,发现多了一个hello.txt文件,成功

     

  • 相关阅读:
    postgres--流复制
    postgres--wal
    postgres--vacuum
    postgres10配置huge_pages
    Postgres间隔大量写IO的解决办法
    PostgreSQL配置文件--其他
    PostgreSQL配置文件--AUTOVACUUM参数
    PostgreSQL配置文件--实时统计
    PostgreSQL配置文件--日志和错误
    PostgreSQL配置文件--QUERY TUNING
  • 原文地址:https://www.cnblogs.com/qiezi-online/p/12950395.html
Copyright © 2011-2022 走看看