科研Day4 -- git命令

本文介绍如何使用Git进行基本的仓库管理,包括配置个人信息、提交代码、查看提交历史等关键步骤,并提供了一些实用的命令帮助理解Git的工作流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用户信息设置

# 设置用户名
git config --global user.name "username"
# 设置邮箱
git config --global user.email "youremail"
# 查看设置
git config --global --list
# 检查 SSH 能否连接到 github
ssh -T git@github.com

上传项目

# 提交代码到暂存区
git add .
# 查看代码修改情况
git status
# 提交暂存区代码到本地git仓库
git commit -m "updata"
# 提交本地git仓库代码到远程仓库
git push

查看历史提交

git log
# 查看历史记录的简洁版本
git log --oneline
# 开启拓扑图选项,查看分支、合并
git log --graph
# 逆向显示日志
git log --reverse --oneline
# 查找指定用户的提交日志
git log --author=nightluo --oneline -5
# 隐藏合并提交
git log --no-merges
# 查找指定日期的日志
git log --before={3.weeks.ago} --after={2022-10-01} --no-merges
git log --since/--until
# more: http://git-scm.com/docs/git-log

# 查看指定文件的修改记录
git blame <file>

github官方文档:https://docs.github.com/en/get-started
1、Managing remote repositories:https://docs.github.com/en/get-started/getting-started-with-git/managing-remote-repositories#switching-remote-urls-from-ssh-to-https
2、Creating a personal access token:https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值