git之简单入门及操作~

看了bili的教程,https://www.bilibili.com/video/av23853294?from=search&seid=3300012850779227291

特此整理下。

1、首先安装git,然后最好国内镜像,否则下载很慢
2、其次,可以注册github的账号,后面会用到。
3、把git和github链接起来,就是建立连接,右键打开git bash here,输入ssh-keygen,会中C:\Users\Administrator\.ssh文件夹下生成两个文件,打开id_rsa.pub,把里面的信息全部拷贝的github之SSH and GPG keys中。这样就把git和github建立了链接。
4、新建一个文件,打开文件,右键git bash here,
可以看到如下信息:

a、git init命令

Administrator@PC-20150323YSLL MINGW64 ~/Desktop/maple_stm_git
$ git init
Initialized empty Git repository in C:/Users/Administrator/Desktop/maple_stm_git/.git/

b、git remote add origin命令,把github的链接和本地文件建立连接
Administrator@PC-20150323YSLL MINGW64 ~/Desktop/maple_stm_git (master)
$ git remote add origin https://github.com/liming2013/maple.git

c、git pull origin master命令,下载代码到本地文件夹中
Administrator@PC-20150323YSLL MINGW64 ~/Desktop/maple_stm_git (master)
$ git pull origin master
remote: Enumerating objects: 233, done.
remote: Total 233 (delta 0), reused 0 (delta 0), pack-reused 233
Receiving objects: 100% (233/233), 7.86 MiB | 74.00 KiB/s, done.
Resolving deltas: 100% (63/63), done.
From https://github.com/liming2013/maple
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
d、git add命令,在文件夹中添加几个文件,然后add到stage区域,中间需要空格。
Administrator@PC-20150323YSLL MINGW64 ~/Desktop/maple_stm_git (master)
$ git add a.c ble_nrf_add.txt

Administrator@PC-20150323YSLL MINGW64 ~/Desktop/maple_stm_git (master)
$ git commit -m "add"
[master d381232] add
2 files changed, 3 insertions(+)
create mode 100644 a.c
create mode 100644 ble_nrf_add.txt

e、git push origin master命令,上传文件之github

Administrator@PC-20150323YSLL MINGW64 ~/Desktop/maple_stm_git (master)
$ git push origin master
Username for 'https://github.com': liming2013
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 2 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 488 bytes | 97.00 KiB/s, done.
Total 4 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/liming2013/maple.git
af0703b..d381232 master -> master

f、“git add .”命令,可以添加文件夹中全部的文件

 

posted @ 2019-05-15 21:49  wdliming  阅读(334)  评论(0编辑  收藏  举报