一些常用到的git命令

git stash -a //缓存所有文件

git checkout -b dev origin/dev //切换到dev分支上,接着跟远程的origin地址上的dev分支关联起来

//推送本地分支到远程仓库

git push origin localbranchname:remotebrancname

git revert onefile //https://www.freecodecamp.org/news/git-revert-file-reverting-a-file-to-a-previous-commit/

//Git中获取当前分支名git

git branch --show-current

//git从指定的commit创建分支

git checkout -b branchname <commit-hash>

//以下两个命令需要在git bash下执行,因为window下找不到grep\xargs命令

//This script will delete all local branches except the master branch, including the non-merged branches.

git for-each-ref --format '%(refname:short)' refs/heads | grep -v "master\|main\|develop" | xargs git branch -D

//The -d is a soft delete option and only removes the merged branches.

git for-each-ref --format '%(refname:short)' refs/heads | grep -v "master\|main\|develop" | xargs git branch -d

//合并某个提交

git cherry-pick <commit-hash>

//列出包含某个提交的所有标签

git tag --contains f3a0b78

//克隆某个Tag的代码

git clone -b v9.2.2 https://gitlab.kitware.com/vtk/vtk.git

//回滚到某个提交

git log --oneline

git reset --hard <commit-hash>

git checkout -b branchname

git push origin localbranchname:remotebranchname

相关推荐
ALex_zry5 小时前
Git大型仓库推送失败问题解决方案:大文件传输优化指南
git
草莓熊Lotso5 小时前
Git 分支管理:从基础操作到协作流程(本地篇)
大数据·服务器·开发语言·c++·人工智能·git·sql
w***Q3508 小时前
Git工作流自动化
运维·git·自动化
舒一笑13 小时前
GitPulse:让代码的故事自己讲述
git·程序员·intellij idea
5***o50014 小时前
Git在代码中的GitHub
git·github
还是会想她15 小时前
git 常见命令
git
1***y17817 小时前
Git在发布流程中的自动化标签
运维·git·自动化
逻辑棱镜1 天前
Git 分支管理与提交信息规范 (v1.0)
git·github·团队开发·代码规范·敏捷流程
悦悦欧呐呐呐呐1 天前
git 设置邮箱和用户名
git
正经教主1 天前
【Git】Git06:Git 管理 Android 项目教程(含GitHub)
android·git