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
相关推荐
Dontla1 小时前
git bash打开Claude code报错:Claude Code on Windows requires git-bash.(别把git装其他位置,严格按照默认安装)找不到claude code
windows·git·bash
一个梦醒了1 小时前
安装git bash选项推荐
开发语言·git·bash
呆萌的代Ma5 小时前
Git不强行推送,撤销最近几次的提交
git
透明的玻璃杯7 小时前
git应用
git
炸炸鱼.9 小时前
Git+Jenkins实战(一):从零搭建自动化发布与回滚系统(附完整代码)
git·jenkins
言66611 小时前
要忽略前端依赖包node_modules的文件在目录下 git暂存区消失
git
胡小禾12 小时前
Git Worktree
git
程序员小羊!12 小时前
18 GIt
git
怣疯knight12 小时前
Git 本地分支关联远程分支 常用命令汇总
git
ANNENBERG13 小时前
git分支开发管理
git