Git 单机版

Git 是一个分布式的开源版本控制系统,也就是说,每台机器都可以充当控制中心,我从本机拉取代码,再提交代码到本机,不需要依赖网络,各自开发各自的

如何创建 git 仓库:

1[root@localhost ~]$ yum install -y git # 安装git 2[root@localhost ~]$ mkdir -p /data/git # 创建要作为git仓库的目录 3[root@localhost ~]$ cd /data/git # 进入该目录 4[root@localhost git]$ git init # 初始化仓库 5[root@localhost git]$ git config --global user.name "Your Name" # 配置用户,以便知道提交代码的人是谁 6[root@localhost git]$ git config --global user.email you@example.com # 配置邮箱,以便联系到提交代码的人

如何提交代码到 git 仓库:

1[root@localhost git]$ touch 1.txt # 创建一个测试文件 2[root@localhost git]$ git add 1.txt # 添加到版本控制中心 3[root@localhost git]$ git commit -m 'add new file 1.txt' 1.txt # 提交到git仓库 4[root@localhost git]$ git status # 查看当前仓库中的状态

修改代码后如何提交到 git 仓库:

1[root@localhost git]$ echo "abc" >> 1.txt # 修改文件内容 2[root@localhost git]$ git diff 1.txt # 还没提交到代码仓库之前,可以对比当前文件跟代码仓库的文件有什么不同 3[root@localhost git]$ git commit -m 'add some character to 1.txt' 1.txt # 提交到代码仓库 4[root@localhost git]$ git status # 查看当前仓库中的状态

如何回滚版本:

1[root@localhost git]$ git log --pretty=oneline # 查看提交过的版本日志 2[root@localhost git]$ git reset --hard 0e6ff268923a54 # 回滚到指定的版本 3[root@localhost git]$ git reflog # git reflog 可以查看所有分支的所有操作记录

如何撤销修改:

1[root@localhost git]$ rm -f 1.txt # 如果我不小心删除了文件,如何恢复回来 2[root@localhost git]$ git checkout -- 1.txt # 重新检出文件即可 3 4[root@localhost git]$ echo "aaa" >> 1.txt # 如果我修改了文件 5[root@localhost git]$ git add 1.txt # 添加到版本控制中心,但这时我不想提交了,想恢复修改前的文件,该如何恢复 6[root@localhost git]$ git reset HEAD 1.txt # 先重置HEADHEAD可以理解为一个游标,一直指向当前我们所在版本库的地址,就是我们当前所在版本库的头指针) 7[root@localhost git]$ git checkout -- 1.txt # 再重新检出文件即可

如何删除文件:

1# 如果我们直接使用 rm -f 1.txt 只是删除了本地文件,版本库里的文件还是没有删除的,因此要用下面的方法[root@localhost git]$ git rm 1.txt # 删除本地文件 2[root@localhost git]$ git commit -m 'delete file 1.txt' # 提交到版本库,会自动把版本库里的文件也删除
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

java将前端的json数组字符串转换为列表

记录下在前端通过ajax提交了一个json数组的字符串,在后端如何转换为列表。前端数据转化与请求varcontracts{id:'1',name:'yanggb合同1'},{id:'2',name:'yanggb合同2'},{id:'3',name:'yang