zoukankan      html  css  js  c++  java
  • git本地与github仓库文件同步

    本地准备工作

    • 下载、安装git
    • 绑定用户
    $ git config --global user.name "Your Name"
    $ git config --global user.email "email@example.com"
    
    • 配置 SSH
    $ ssh-keygen -t rsa -C "youremail@example.com"
    

    在GitHub创建仓库

    Create repository

    同步

    • 克隆远程仓库
    git clone https://github.com/***/Linear.git
    
    • 进入克隆的仓库,进行初始化
    git init
    
    • 如果不包含readme.md,则创建并上传README.md文件
    $ git init
    $ touch README.md
    $ git add README.md
    $ git commit -m 'first_commit'
    $ git remote add origin https://github.com/***/Linear.git
    $ git push origin master
    
    • 跟踪项目文件夹中的所有文件和文件夹
    $ git add .
    
    • 输入本次的提交说明(必须提交说明,否则无法上传)
    $ git commit -m 'this_commit'
    
    • 关联远程仓库
    $ git remote add origin https://github.com/***/Linear.git
    

    origin为远程仓库名,是Git的默认叫法,也可以为别的。

    • 若出现错误 fatal: remote origin already exists,则执行以下语句再关联
    $ git remote rm origin
    
    • 把本地库的所有内容推送到远程库上
    $ git push -u origin master
    
    • 如果在推送时出现错误 error:failed to push som refs to.......,则执行下列语句
    $ git pull origin master
    

    将远程库中的内容拉下来再重新推送上去

    • 上传大文件
    # 1、安装git-lfs
    brew install git-lfs
    
    # 2、没有特别说明的情况下,LFS 不会处理大文件问题,因此,我们必须明确告诉 LFS 该处理哪些文件。
    git lfs track "FrameworkFold/XXXFramework/xxx" # 追踪单个文件
    git lfs track "*.exe" # 追踪指定类型的文件
    git lfs track "FrameworkFold/*" 追踪指定目录下的文件
    
    # 3、常规push操作
    git add .
    git commit -m "add large file"
    git push
    
  • 相关阅读:
    用Python实现谷歌的小恐龙游戏
    nyoj_187_快速查找素数_201312042102
    nyoj_218_Dinner_201312021434
    nyoj_66_分数拆分_201312012122
    nyoj_524_A-B Problem_201312012035
    hdu_2054_A == B_201311301601
    nyoj_655_光棍的yy_201311281539
    nyoj_111_分数加减法_201311281341
    nyoj_60_谁获得了最高奖学金_201311281117
    nyoj_264_国王的魔镜_201311271800
  • 原文地址:https://www.cnblogs.com/rookieveteran/p/12639374.html
Copyright © 2011-2022 走看看