版本控制系统的使用笔记(git,svn)

本文详细介绍了Git和SVN的基本操作,包括Git的安装、配置、版本控制操作,如add、commit、push,以及分支管理和回溯版本。同时提到了使用VScode进行Git操作的便利性。对于SVN,文章虽未展开详细说明,但提供了相关链接供进一步学习。此外,还推荐了一个用于查看Git提交历史的VScode插件。
摘要由CSDN通过智能技术生成

一、git

1、初始化

        1)、安装下载         sudo apt-get install git

        2)、全局配置                 

//config 配置 global 全局
git config --global user.name "xxx"    //用户名
git config --global user.email "xxx"    //用户邮箱

        3)、创建公钥,ssh-keygen -C '个人email' -t rsa

        (ssh 和-keygen之间没有空格,一直回车就好)

        git通过ssh方式访问资源库,故在~./ssh/id_rsa.pub中创建了相应的密钥。此密钥需要粘贴到github中。

        粘贴完成后可使用ssh -T git@git.oschina.net,来检测是否成功,成功显示:“Hi fangcheng21! You've successfully authenticated, but GitHub does not provide shell access.”

        4)、当前目录        git init 。

                创建.git隐藏文件夹,该文件夹会保存每个版本的记录及变化。

        5)、链接到Github:  git remote add origin git@github.com:fangcheng21/MyUbuntu.git

                后面为项目地址。想要解除更换链接可以使用:git remote rm origin。

2、git使用

        继git init在目录中初始化之后

        1)git add XXX,添加XXX文件到版本控制系统(暂存)。

                        当文件过多使用git add . 。表示当前目录的所有文件。

        2)git commit -m "注释(例修改内容为xxx)" ,将暂存保存为新版本。

                        也可直接git commit,然后跳出注释编辑界面,在其中写入注释。

                        git是按行来比对文件的不同,两种情况,新增、删除。

        3)git log 可以查看提交信息

              git log --graph 显示提交树的merge关系

              git log --name-status 显示新增、修改和删除的文件清单

# 显示提交树的merge关系
git log --graph

                

        4)git status 查看暂存区状态

        5)git push origin master/main 将本地信息同步到Github

        6)    git branch XX 创建新分支

        7)git checkout XX 切换分支

        8)git merge XX 合并分支  需要在主分支下进行

        9)回溯版本:git reset --hard commitID(git log 查看)

                --hard硬回溯模式,还有--soft,--mixed(默认)模式。

        10)git show 查看某次提交的修改内容

        除终端外,VScode也能够兼容使用git并且更加方便,补一个插件git history diff方便查看提交历史。

学习查询路径:      不把Git基本操作|菜鸟教程https://www.runoob.com/git/git-basic-operations.htmlhttps://www.runoob.com/git/git-basic-operations.htmlhttps://www.runoob.com/git/git-basic-operations.htmlhttps://www.runoob.com/git/git-basic-operations.htmlhttps://www.runoob.com/git/git-basic-operations.htmlhttps://www.runoob.com/git/git-basic-operations.htmlhttps://www.runoob.com/git/git-basic-operations.htmlhttps://www.runoob.com/git/git-basic-operations.htmlhttps://www.runoob.com/git/git-basic-operations.htmlicon-default.png?t=N7T8https://www.runoob.com/git/git-basic-operations.html

二、SVN

链接

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值