• ubuntu同步本地代码到github最新版


    1.下载,安装
    一般情况下ubuntu配置了git,如果没有话通过如下命令进行下载

    sudo apt-get install git-all
    
    • 1

    2.创建本地的git仓库

    1. 初始化git仓库
    git config --global user.name "xxx"
    git config --global user.email "xxx@email.com"
    git init
    
    • 1
    • 2
    • 3
    1. 将代码放到缓冲区
    git add .
    
    • 1
    1. 添加文件备注名,将缓存区的文件进行提交
    git commit -m first
    
    • 1

    3.获取token等信息

    1. 打开Github,在个人设置页面,找到【Setting】,然后打开找到【Devloper Settting】
    2. 然后,选择个人访问令牌【Personal access tokens】,然后选中生成令牌【Generate new token】
    3. 要使用token从命令行访问仓库,请选择repo要使用token从命令行删除仓库,请选择delete_repo其他根据需要进行勾选。然后,点击【Generate token】生成令牌。
    4. 生成token后,记得把你的token保存下来,以便进行后面的操作。
    5. 本地终端输入
    git remote set-url origin https://<your_token>@github.com/<USERNAME>/<REPO>.git
    <your_token>:换成你自己得到的token
    <USERNAME>:是你自己github的用户名
    <REPO>:是你的仓库名称
    
    • 1
    • 2
    • 3
    • 4

    例如git remote set-url origin https://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@github.com/shliang0603/
    4.将本地的push到github仓库

    git push -u origin master
    或者 git push -u origin master:main。这时就可以把本地的master分支push到远程的main分支
    
    • 1
    • 2

    可能问题1

    $ git push origin master
    To http://xxxxxx/test.git
     ! [rejected]        master -> master(fetch first)
    error: failed to push some refs to 'http://xxxxxx/Android.git'
    hint: Updates were rejected because the remote contains work that you do
    hint: not have locally. This is usually caused by another repository pushing
    hint: to the same ref. You may want to first integrate the remote changes
    hint: (e.g., 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    github上代码有些没有同步到本地,先同步再push

    git pull origin
    git push origin master
    
    • 1
    • 2

    可能问题2

    remote: Support for password authentication was removed on August 13, 2021. Please use a person
    
    • 1

    由于密码登入被弃用,所以应该采用步骤3中所提到的过程用token进行登入。

  • 相关阅读:
    【开发工具】vConsole - 手机前端开发调试利器
    什么是SpringCloud Eureka服务注册与发现
    踩雷react-useRef钩子函数
    在ubuntu64下实现 小型 C 运行时库
    高级IO详解——五种IO模型
    线上宕机问题(索引问题)
    【机器学习基础】正则化
    TDesign:腾讯的企业级前端框架,对标elementUI和ant-design
    这 30 个常用的 Maven 命令你必须熟悉!
    点云从入门到精通技术详解100篇-基于三维点云的路况语义分割(续)
  • 原文地址:https://blog.csdn.net/qq_42061298/article/details/126570787