问题描述

本文回答的问题是:Ubuntu环境下,如何通过Git命令将源代码上传到远程Github服务器。


解决方案

步骤一:当前目录下,克隆目标Github项目 (备注:可能需要成功设置Github Token, 新版的Github需要用Token(口令) 替代 Password(密码))

$ cd home
$ git clone https://github.com/XXX.git (-b main)

步骤二:修改Github XXX项目

$ cd home/XXX
$ touch aNewFile

步骤三:commit相关修改

$ git add .
$ git commit -m "touch a new file"

步骤四:push相关修改

$ git push origin main --force

最后

测试日志 on 26 April 2024: 测试通过。如果每次git push都要输入Username, Password,那么解决方案如下:

$ git config --global credential.helper store
$ git config --global credential.helper "cache --timeout 7200"

测试日志 on 25 April 2024: 测试通过。The error message is as follows.

git push missing or invalid credentials errno: -111 missing or invalid credentials. missing or invalid credentials.

上述问题可以通过Github账号信息配置+重启ubuntu系统来解决。

测试日志 on 10 Nov 2022:测试通过。

测试日志 on Nov 09, 2022:测试失败。失败详情是如果没有配置Github账户信息,需要根据系统提示配置下列两行信息,

*** Please tell me who you are.

Run

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

to set your account's default identity.
Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐