GIT操作学习

本文档详尽地介绍了 Git 的基本使用方法,包括本地仓库的管理、分支的创建与合并、远程仓库的同步等核心操作流程。适用于初学者快速入门及进阶使用者查阅。

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

[git]基本命令
1、windows下载git工具[https://git-for-windows.github.io]
2、配置GIT用户名[git config --global user.name "ada"][git config --global user.email "123@126.com"]
3、创建目录[makdir leargit][cd][cd ..][pwd]
4、创建并初始化git库,进入目录后再执行[git init]
5、添加[git add xxx.file] 上传[git commit -m “描述说明”]
6、文件操作[git status][git diff xxx.file][git log --pretty=oneline][git reflog]
7、文件回退[git reset --hard HEAD^ xxx.file]
8、文件获取[git checkout -- xxx.file]
9、文件删除[git rm xxx.file][git commit -m"delect file"]
10、文件查看 [vi ***.file],退出文件[:q]


[git]分支操作
1、创建并切换分支[git checkout -b branch-name]==[git branch branch-name]+[git checkout branch-name]{切换分支}
2、查看当前有哪些分支 [git branch]
3、[git checkout branch-name][git checkout master],是操作最后的一个文件
4、合并当前操作的文件 branch到master [git merge branch-name][git merge --no-ff -m "comment" branch-name]
   {遇到冲突,先解决冲突。[git status]->[git log --graph --pretty=oneline --abbrev-commit]}
   {master上 重新add、commit}
5、删除分支[git branch -d branch-name] 强行删除分支[git branch -D branch-name]
6、暂存工作环境 [git stash] 还原工作环境[git stash list]->[git stash pop],或者指定还原[git stash apply stash@{0}]->[git stash drop]


[git]远程库的操作
1、创建KEY[ssh-keygen -t rsa -C"123@126.com"]
2、创建并关联[git remote add origin git@github.com:Aiwenada/***.git]
3、远程推送[git push -u origin master{branch-name}],后续可用[git push origin master{branch-name}]
4、远程克隆[git clone git@github.com:Aiwenada/***.git]
5、获取远程库分支[git checkout -b branch-name origin/branch-name]
6、本地分支与远程分支关联[git branch --set-upstream branch-name origin/brach-name]
7、抓取远程[git pull]
8、获取远程仓库的详细信息[git remote -v]


[git]标签操作
1、获取标签[git tag]
2、创建标签[git tag {tag-name} {commitID}] 默认打在最后一次commit
3、查看标签[git show {tag-name}]


github.com操作
1、fork获取开源代码到自己的github









评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值