Git命令

配置用户名和邮箱

git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"

查看 Git 配置信息

git config --list

初始化 Git 仓库

git init

克隆远程仓库

git clone <repository-url>

查看工作区状态

git status

将新文件添加到暂存区

git add <file>

将当前目录下的所有修改添加到暂存区

git add .

提交暂存区中的更改并附加注释

git commit -m "Commit message"

跳过暂存区直接提交

git commit -a -m "Commit message"

删除文件并从暂存区移除

git rm <file>

移动或重命名文件

git mv <old_name> <new_name>

查看提交历史

git log

以简洁格式显示提交历史

git log --oneline

显示指定文件的修改历史

git log -p <file>

图形化展示所有分支提交历史

git log --graph --all --oneline

查看本地分支

git branch

创建一个新分支

git branch <branch_name>

切换到指定分支

git checkout <branch_name>

创建并切换到新分支

git checkout -b <branch_name>

将指定分支合并到当前分支

git merge <branch_name>

删除本地分支

git branch -d <branch_name>

强制删除未合并的分支

git branch -D <branch_name>

查看远程分支

git branch -r

列出远程仓库的 URL

git remote -v

添加一个远程仓库

git remote add <name> <url>

删除远程仓库

git remote remove <name>

将本地分支推送到远程分支

git push <remote> <branch>

拉取并合并远程分支的代码

git pull <remote> <branch>

下载远程分支的更新

git fetch <remote>

推送标签到远程

git push <remote> --tags
相关推荐
2501_9032386515 分钟前
Git Bash:Windows下的强大命令行工具
windows·git·bash·个人开发
神明木佑2 小时前
datalist 是什么?以及作用是什么?
git
那片海还在吗4 小时前
使用 Git、Postman、Newman、Jenkins 与邮件构建自动化接口测试及通知流程
git·jenkins·postman
heeheeai12 小时前
git 国内源
git
the_seventh_dog12 小时前
git | 团队协作开发注意事项
git
yinshuilan15 小时前
今日运维之-Mac笔记本python环境问题
运维·git·python·brew
辄也16 小时前
git拉取远程分支到本地分支
git
皮克斯的进化之路16 小时前
Git原理+使用(超详细)
git
wrjwww17 小时前
【Git学习笔记】Git常用命令
笔记·git·学习
大乔乔布斯17 小时前
WSL,Power shell 和CMD, Git bash的区别
开发语言·git·bash