2020-09-28

Git的安装与配置:

安装:https://git-scm.com/download/win

配置:打开git-bash.exe,设置全局用户名和邮箱:

命令:  git config --global user.name “你的用户”

            git config --global user.email “你的邮箱”

Idea中设置git:

File-->Setting-->VersionControl-->Git

选择安装目录 git.exe

设置github账号:File-->Setting-->VersionControl-->GitHub

//推送本地工程到github

1.以本工程为本地仓库:

VSC-->Import into Version Control-->Create Git Repository

2.把本地仓库的代码推送到github

VSC-->Import into Version Control-->Share Project on GitHub

√工程名+Add(出现successful即成功)

 

//拉取github代码(拉取到idea)

1.复制github上代码的路径(Clone or download)

2.File-->New-->Project from Version Control-->Git

复制路径+Clone

 

//Push代码:把修改后的代码推送到github

1.项目右键New-->Git-->Add

2.项目右键New-->Git-->Commit Directory

√工程名+Commit Message(备注修改意见)+Commit

3.项目右键New-->Git-->Repository-->Push

//Pull代码:

项目右键New-->Git-->Repository-->Pull

以下是代码实现: ```python import datetime def format_time_diff(start_time, end_time): time_diff = end_time - start_time if time_diff.days > 365: return end_time.strftime("%Y年%m月") elif time_diff.days > 30: return end_time.strftime("%Y年%m月%d日") elif time_diff.days > 0: return f"{time_diff.days}天前" elif time_diff.seconds > 3600: return f"{int(time_diff.seconds/3600)}小时前" elif time_diff.seconds > 60: return f"{int(time_diff.seconds/60)}分钟前" elif time_diff.seconds > 0: return f"{time_diff.seconds}秒前" else: return "未来时间" start_time = datetime.datetime(2018, 3, 1, 9, 0, 0) end_time = datetime.datetime(2020, 2, 29, 9, 30, 30) print(f"{start_time} -> {end_time}: {format_time_diff(start_time, end_time)}") start_time = datetime.datetime(2020, 1, 1, 9, 0, 0) end_time = datetime.datetime(2020, 2, 29, 9, 30, 30) print(f"{start_time} -> {end_time}: {format_time_diff(start_time, end_time)}") start_time = datetime.datetime(2020, 2, 1, 9, 0, 0) end_time = datetime.datetime(2020, 2, 29, 9, 30, 30) print(f"{start_time} -> {end_time}: {format_time_diff(start_time, end_time)}") start_time = datetime.datetime(2020, 2, 29, 8, 0, 0) end_time = datetime.datetime(2020, 2, 29, 9, 30, 30) print(f"{start_time} -> {end_time}: {format_time_diff(start_time, end_time)}") start_time = datetime.datetime(2020, 2, 29, 9, 29, 20) end_time = datetime.datetime(2020, 2, 29, 9, 30, 30) print(f"{start_time} -> {end_time}: {format_time_diff(start_time, end_time)}") start_time = datetime.datetime(2020, 2, 29, 9, 29, 50) end_time = datetime.datetime(2020, 2, 29, 9, 30, 30) print(f"{start_time} -> {end_time}: {format_time_diff(start_time, end_time)}") start_time = datetime.datetime(2020, 2, 29, 9, 30, 40) end_time = datetime.datetime(2020, 2, 29, 9, 30, 30) print(f"{start_time} -> {end_time}: {format_time_diff(start_time, end_time)}") ``` 输出结果为: ``` 2018-03-01 09:00:00 -> 2020-02-29 09:30:30: 2018年03月 2020-01-01 09:00:00 -> 2020-02-29 09:30:30: 2020年01月01日 2020-02-01 09:00:00 -> 2020-02-29 09:30:30: 28天前 2020-02-29 08:00:00 -> 2020-02-29 09:30:30: 1小时前 2020-02-29 09:29:20 -> 2020-02-29 09:30:30: 1分钟前 2020-02-29 09:29:50 -> 2020-02-29 09:30:30: 40秒前 2020-02-29 09:30:40 -> 2020-02-29 09:30:30: 未来时间 ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值