linux&githubGit

2、初步学习Git基本命令

2019-02-28  本文已影响182人  m小萌同学

1、下载安装Git

2、基本命令

2.1 全局配置用户名、邮箱:

在桌面右击选择Git Bash Here


Git Bash.jpg

输入:

2.2 初始化仓库

2.3 向仓库中添加文件

#   1.个人简介
##  1.1基本情况
##  1.2联系方式
D:\learngit>git add README.md
D:\learngit>git commit -m "Personal profile"
[master (root-commit) 8a40766] Personal profile
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 README.md
D:\learngit>

2.4 修改文件

#   1.个人简介
##  1.1基本情况
##  1.2联系方式

#   2.教育经历
##  2.1学历教育
##  2.2继续教育
D:\learngit>git add README.md
D:\learngit>git commit -m "Educational experience"
[master (root-commit) 8a40766] Personal profile
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 README.md
D:\learngit>

先添加后提交!!!

2.5 查看当前仓库状态

D:\learngit>git status
On branch master
nothing to commit, working tree clean

2.6 查看版本历史记录

D:\learngit>git log
commit 8a407662d739f3cade254dcd504016b56545799e (HEAD -> master)
Author: Invader <1292689963@qq.com>
Date:   Fri Mar 1 08:55:19 2019 +0800

    Educational experience
commit 2b2224963f65e96f36cdcd53654fda25e69697e43
Author: Invader <1292689963@qq.com>
Date:   Fri Mar 1 08:53:36 2019 +0800

    Personal profile
D:\learngit>git log --pretty=oneline
D:\learngit>git log --pretty=oneline
8a407662d739f3cade254dcd504016b56545799e (HEAD -> master) Educational experienxce
2b2224963f65e96f36cdcd53654fda25e69697e43 Personal profile

8a407662d739f3cade254dcd504016b56545799e : commit id

2.7穿越到指定版本

D:\learngit>git reset --hard 8a407662
HEAD is now at 8a40766 Personal profile

2.8 多个文件同时提交

D:\learngit>git add log.txt

D:\learngit>git add me.jpg
D:\learngit>git commit -m "add log.txt and me.jpg files"
[master f6e6945] add log.txt and me.jpg files
 2 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 log.txt
 create mode 100644 me.jpg
D:\learngit>git log --pretty=oneline
f6e6945d4ead3261589d59e51d8c23b433528dfc (HEAD -> master) add log.txt and me.jpg files
2b2224963f65e96f36cdcd53654fda25e69697e43 Educational experience
8a407662d739f3cade254dcd504016b56545799e Personal profile

3、课后小结

git config core.autocrlf true

上一篇 下一篇

猜你喜欢

热点阅读