2020-11-20

1.git的基础

1.1 什么是git

Git是一个版本管理控制系统(缩写VCS),它可以在任何时间点,将文档的状态作为更新记录保存起来,也可以在任何时间点,将更新记录恢复回来。
在这里插入图片描述

1.2什么是版本管理

版本管理是一种记录文件变化的方式,以便将来查阅特定版本的文件内容。
在这里插入图片描述

2.git的使用

2.1git 使用前配置

  1. 配置提交人姓名:git config --global user.name 提交人姓名
  2. 配置提交人姓名:git config --global user.email 提交人邮箱
  3. 查看git配置信息:git config --list (分别查看 git config user.name || git config user.email)
    注意
  4. 如果要对配置信息进行修改,重复上述命令即可。
  5. 配置只需要执行一次。

2.2提交步骤

  1. git init 初始化git仓库 (mac中Command+Shift+. 可以显示隐藏文件)
  2. git status 查看文件状态
  3. git add 文件列表 追踪文件
  4. git commit -m 提交信息 向仓库中提交代码
  5. git log 查看提交记录

2.3撤销

用暂存区中的文件覆盖工作目录中的文件: git checkout --文件名
将文件从暂存区中删除: git rm --cached 文件名
将 git 仓库中指定的更新记录恢复出来,并且覆盖暂存区和工作目录:git reset --hard commitID
在这里插入图片描述

2.4分支命令

git branch 查看分支
git branch 分支名称 创建分支
git checkout 分支名称 切换分支
git merge 来源分支 合并分支 (备注:必须在master分支上才能合并develop分支)
git branch -d 分支名称 删除分支(分支被合并后才允许删除)(-D 强制删除)

2.5暂时保存更改

在git中,可以暂时提取分支上所有的改动并存储,让开发人员得到一个干净的工作副本,临时转向其他工作。
使用场景:分支临时切换
存储临时改动:git stash
恢复改动:git stash pop

可以通过Java的日期时间类 `LocalDate` 和 `LocalDateTime` 来实现该功能。 首先,我们需要将时间段转换为 `LocalDateTime` 对象,然后将时间部分设置为 00:00:00 或 23:59:59,最后遍历每一天,获取每一天的开始时间和结束时间。 以下是代码示例: ```java import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.time.format.DateTimeFormatter; public class TimeUtils { public static void main(String[] args) { String startStr = "2020-11-20 09:09:09"; String endStr = "2021-10-09 10:10:10"; DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); LocalDateTime start = LocalDateTime.parse(startStr, formatter); LocalDateTime end = LocalDateTime.parse(endStr, formatter); // 将时间部分设置为 00:00:00 或 23:59:59 LocalDateTime startOfDay = start.with(LocalTime.MIN); LocalDateTime endOfDay = end.with(LocalTime.MAX); // 遍历每一天,获取每一天的开始时间和结束时间 LocalDate startDate = startOfDay.toLocalDate(); LocalDate endDate = endOfDay.toLocalDate(); while (!startDate.isAfter(endDate)) { LocalDateTime startOfDayOfDate = startDate.atStartOfDay(); LocalDateTime endOfDayOfDate = startDate.atTime(LocalTime.MAX); System.out.println("Start time of " + startDate + ": " + startOfDayOfDate); System.out.println("End time of " + startDate + ": " + endOfDayOfDate); startDate = startDate.plusDays(1); } } } ``` 输出结果如下: ``` Start time of 2020-11-20: 2020-11-20T00:00 End time of 2020-11-20: 2020-11-20T23:59:59.999999999 Start time of 2020-11-21: 2020-11-21T00:00 End time of 2020-11-21: 2020-11-21T23:59:59.999999999 ... Start time of 2021-10-09: 2021-10-09T00:00 End time of 2021-10-09: 2021-10-09T23:59:59.999999999 ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值