第二次作业:分布式版本控制系统Git的安装与使用

作业的要求来自于:https://edu.cnblogs.com/campus/gzcc/GZCC-16SE2/homework/2097

远程仓库的地址:https://github.com/Chenqishu/cqs

分布式版本控制系统Git基本操作


1. 下载安装配置用户名和邮箱。

修改用户名    $ git config --global user.name "username"                  

修改邮箱地址    $ git config --global user.email  "email"                            

查看用户名    $ git config user.name

查看邮箱    $ git config user.email

2. 创建工作目录并通过git init命令把这个目录变成Git可以管理的仓库。

查看仓库工作目录地址    $ pwd

改变Git管理的仓库地址    $ git init

3. 在工作目录下准备文本文件,建议下载Notepad++代替记事本

Notepad++

工作路径

4. 组合用git add、git commit、git status 把文件提交到仓库

添加文件到仓库    $ git add

提交文件到仓库    $ git commit ( -m 后面可添加修改备注 )

检查当前文件状态    $ git status 

5. 练习提交三个或以上的版本

 

6. 组合使用git diff、git log、git reset命令进行版本管理与回退,观察文件变化。 

显示从最近到最远的提交日志(单行显示版本信息)   $ git log --pretty=oneline

 

查看具体修改内容    $ git diff

回到某一个版本    $ git reset 

确定后从第四版本跳到第三版本

7. Git仓库托管到GitHub网站上。

 创建SSH Key :$ ssh-keygen -t rsa -C "[email protected]"

用记事本打开公钥id_rsa.pub

登陆GitHub,打开“settings”,“SSH and GPG keys”页面:

然后,点“New SSH Key”,填上Title,在Key文本框里粘贴id_rsa.pub文件的内容

8. 把本地仓库的内容推送到GitHub仓库

建立了本地仓库与远程库关联  $ git remote add origin [email protected]:yourAddress/yourGit.git

本地库的所有内容推送到远程库  $ git push -u origin master

 完毕

猜你喜欢

转载自www.cnblogs.com/fulanjiang/p/9651964.html