git远程上传文件至github

一、本地安装和配置git
1、安装git

pacman -S git          //如果没有问题的话就可以安装成功了

2、验证

git --version          //看到结果git version 2.10.2就可以了

3、将当前用户添加到wheel组,方便使用sudo(不是必须的)

usermod username -aG wheel      //用root用户

4、添加git用户信息,将yourname换成你自己注册的用户名

git config --global user.name "yourname"      

5、添加git用户信息邮箱,将yourname@aliyun.com换成你自己注册时的邮箱

git config --global user.email " yourname@aliyun.com"      

6、修改git的其他配置,主要有颜色和默认编辑器

git config --global color.ui auto
pi@raspberrypi:~ $ git config --global core.editor vim              //默认为nand,改为vim

7、校验git的配置

git config --list

结果应该是下面的样子:

user.name=username
user.email=username@aliyun.com
color.ui=auto
core.editor=vim   

2.远程上传文件

首先在github 上创建一个仓库,也可以创建一个组,几个人一个组创建一个仓库,共同去完成 任务并且可以资源共享。

在创建完仓库之后,然后进入终端,下载git

首先把仓库克隆到git上,命令为

:git clone https://github.com/jjuc/developRos.git

在终端输入git 就可以看到很多指令   jjuc代表我自己创的组,developRos 表示我创的仓库。

成功如下

qqtsj@qqtsj-Nitro-AN515-51:~$ git clone https://github.com/jjuc/developRos.git
正克隆到 'developRos'...
remote: Enumerating objects: 223, done.
remote: Counting objects: 100% (223/223), done.
remote: Compressing objects: 100% (173/173), done.
remote: Total 223 (delta 92), reused 160 (delta 41), pack-reused 0
接收对象中: 100% (223/223), 38.46 KiB | 307.00 KiB/s, 完成.
处理 delta 中: 100% (92/92), 完成.

然后在git的developRos目录下创建你的文件并敲写你的代码

然后执行下列操作

git add .
git commit

 

每次上传文件时,要保证库处于最新状态

可用 git pull  验证一下

最后上传文件

git push

成功如下

qqtsj@qqtsj-Nitro-AN515-51:~/developRos/tan_py$ vim lock.py
qqtsj@qqtsj-Nitro-AN515-51:~/developRos/tan_py$ git commit -m 'first_commit'
[master f8f7956] first_commit
 1 file changed, 23 insertions(+)
 create mode 100644 tan_py/lock.py
qqtsj@qqtsj-Nitro-AN515-51:~/developRos/tan_py$ git remote add origin https://github.com/findingsea/myRepoForBlog.git
fatal: 远程 origin 已经存在。
qqtsj@qqtsj-Nitro-AN515-51:~/developRos/tan_py$ git pull
已经是最新的。
qqtsj@qqtsj-Nitro-AN515-51:~/developRos/tan_py$ git push
Username for 'https://github.com': tanshengjiang
Password for 'https://tanshengjiang@github.com': 
对象计数中: 4, 完成.
Delta compression using up to 4 threads.
压缩对象中: 100% (4/4), 完成.
写入对象中: 100% (4/4), 586 bytes | 586.00 KiB/s, 完成.
Total 4 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/jjuc/developRos.git
   61048ab..f8f7956  master -> master

 

posted @ 2019-10-28 11:25  拼命的骡子  阅读(236)  评论(0编辑  收藏  举报