git版本管理基础学习

Git基础学习


有兴趣的小伙伴可以添加一下QQ交流群哦:1090397302

Git下载

1.进入 https://gitforwindows.org/ 下载GitHub
2.下载完毕后在桌面上右键选择Git Bast Here

Git使用

打开Git Bast Here输入此命令配置用户名和邮箱

$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"

1.创建版本仓库

$ mkdir myfile

2.进入文件夹

cd myfile

3.查看目录

pwd

4.将此目录变成一个仓库
输入这个命令后当前文件夹会出现一个.git的目录,这个目录是Git来跟踪管理版本库的
没事的时候千万不要手动修改里面的内容,否则git仓库将被破坏掉

git init

5.在myfile目录下新建一个文本index.txt,在index.txt中写出以下内容

We don't talk anymore.
Like we used to do.

6.将index.txt添加到仓库

$ git add index.txt

7.将index.txt提交到仓库

$ git commit -m "create a index file"

-m后面是本次提交的说明,返回的 1 file changed表示有一个文件发生改动,2 insertions表示插入了两行内容。

8.修改文件:首先将index.txt文件的第一行修改一下,修改后如下

We don't talk anymore.  Yes.
Like we used to do.

9.使用git status查看当前仓库的修改状态:

$ git status

返回的内容 modified: index.txt 告诉我们 index.txt 被修改了。

10.查看具体修改的是什么内容,使用:

$ git diff

可以看出 index.txt 被修改了,修改内容是We don’t talk anymore.这一句被改成了+We don’t talk anymore. Yes.

11.知道了修改内容,认为没有什么问题后就可以将它添加到仓库里面了

$ git add index.txt

12.添加过后就可以提交到仓库了

$ git commit -m "create a readme file"

13.这个命令是可以查看你的文件内有什么内容

cat readme.txt

执行到这里以后,进行以下操作(命令行页面请勿关闭)

14.进入GitHub官网,点击右上角的加号选择New repository
填写名称,点击提交
在这里插入图片描述

提交后会出现以下界面:
在这里插入图片描述

15.添加一个名为 origin 的远程仓库(复制上图红框中的内容)

$ git remote add origin git@github.com:cuihua-cuihua/ch-index.git

16.把本地仓库的变化连接到远程仓库主分支

$ git pull origin master --allow-unrelated-histories

17.最后把本地内容推送到远程库

$ git push -u origin master

完~

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值