linux下将本地文件上传到github中?

今天编写一份Python基础代码,经过Linux上传到github上,遇到点问题,已经解决

1.首先sudo su 进入root 用户

2.ls 检查出当前文件下有什么文件

3. cd 进入你将要上传的文件夹下

4.git init(在本机上想要创建一个新的git仓库)

5.git add -A(这里的-A是指将目标文件的所有文件都添加到git中,若不需要添加所有文件,可将-A换成具体的文件名)

6.git commit -m “firstCommit” ("firstCommit" 也可以改成其他的说明性的文字,最终会显示在 github 界面 文件名的后边)

7.git remote add origin xxxxxxxxx xxxxxx就是你仓库的地址(第一次创建仓库的时候使用,下一次上传文件时,不需要此步骤,否者会显示你远程已经有仓库)

 

  

在第一次上传代码时 出现了以下情况:

*** 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.

Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'crystal@crystal-Inspiron-5425.(none)')

这里是让你输入全局项目的 user.email 和 user.name.当然每个项目也可以设置局部的user.email 和 user.name. 由于初步使用,故根据提示输入以下指令

git config --global user.email "*****@gmail.com"

git config --global user.name "crystal"

8.git push origin master>>如果你是第一次用(git push -u origin master) 将本地repo于远程的origin的repo合并,第一次用-u,系统要求输入账号密码

此时会出现

Username for 'https://github.com':

Password for 'https://crystal30@github.com':

根据提示输入github帐号密码即可

9.登录到你的github上查看即可

原文地址:https://www.cnblogs.com/cswzp/p/9982974.html