git使用

clone所有分支

bash 复制代码
git clone ${github_link}

clone指定分支

bash 复制代码
git clone -b ${branch_name} ${github_link}

拉取最新代码

bash 复制代码
git pull origin ${branch_name} 

关联他人远程仓库

bash 复制代码
git remote add ${upstream_name} ${upstream_link}

拉取他人远程分支

bash 复制代码
git pull ${upstream_name} ${branch_name} 

查看版本号与备注

bash 复制代码
git log --pretty=oneline

切换分支

bash 复制代码
git checkout ${branch_name}

切换到指定commit

bash 复制代码
git reset --hard ${commit}

分支未修改完 需要切换其他分支

1.隐藏已修改内容
bash 复制代码
git stash
2.恢复隐藏内容
bash 复制代码
git stash pop
or
git stash apply

查看操作记录

bash 复制代码
git reflog

修改最新的提交的commit说明

bash 复制代码
git commit -amend

修改之前的提交的commit

bash 复制代码
git rebase -i HEAD~5

光标移动到修改的那行把 pick 改为 r 保存 会弹出窗口修改文本

合并之前提交的commit

bash 复制代码
git rebase -i HEAD~5

光标移动到修改的那行把 pick 改为 s 保存 会弹出窗口修改文本

强制更新

bash 复制代码
git push -f 

删除本地在远程没有的分支

bash 复制代码
git remote prune origin
相关推荐
7177771 小时前
Git自建用什么工具比较好:Gitea、Forgejo、GitLab CE与Gitee的选型对比
git·gitlab·gitea
lsc_blog20 小时前
年底还在招的岗位,先确认缺口和到岗要求
git·缓存·ci/cd·职场和发展·github
全栈陈序员1 天前
【Git】从入门到精通(十一)—— git reset 三种模式详解
git·elasticsearch
全栈陈序员1 天前
【Git】从入门到精通(十)—— 撤销与恢复:git checkout与git restore
运维·网络·数据库·git
全栈陈序员1 天前
【Git】从入门到精通(五)—— git add:将文件加入暂存区
大数据·git·elasticsearch
全栈陈序员2 天前
【Git】从入门到精通(七)—— git status:查看仓库状态
大数据·git·elasticsearch
莫晓燚2 天前
Ansible 13 个常用模块---企业实战
git·github
无言听风雨丶2 天前
Kubernetes GitOps 持续交付实战:用 Argo CD 让 Git 成为集群事实源
git·elasticsearch·kubernetes
全栈陈序员2 天前
【Git】从入门到精通(六)—— git commit:提交到版本库
大数据·git·elasticsearch
全栈陈序员3 天前
【Git】从入门到精通(一)—— Git简介:什么是版本控制系统
大数据·git·elasticsearch