一些常用到的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

相关推荐
2301_809815257 小时前
Git和Gitee基本使用教程
git·gitee
雨翼轻尘7 小时前
01_Git概述及基本操作
git·概述·基本操作
程序员果子10 小时前
CrewAI :当 Agent 学会团队协作
人工智能·git·python·多智能体·agent框架
‎ദ്ദിᵔ.˛.ᵔ₎10 小时前
Git GDB/CGDB调试器
git·gdb
他们都叫我GPT侠12 小时前
【无标题】
git·github
果汁华12 小时前
CLI 命令行与 Python 框架实战
git·python·github
zzzzzz31013 小时前
我用 AI Agent 重构了日常开发工作流,效果出乎意料
人工智能·git·github
我叫黑大帅1 天前
git 的 NFD 与 NFC 有什么区别?为什么我有个文件在 NFC 中间不会被当成改动,在 NFD 中就会当成改动
git·面试·github
呆萌很1 天前
Git push 408 超时、远程断开解决办法
git
Lesile1 天前
Hands-on Git experience
git