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

相关推荐
凯子坚持 c3 小时前
Git 多人协作深度解析:从工作流模拟到仓库维护
git
要站在顶端6 小时前
克隆大型仓库卡住(7%每次就卡住了)
git
五月底_7 小时前
上传大量文件到github repo
git·github
rannn_11115 小时前
【Git教程】概述、常用命令、Git-IDEA集成
java·git·后端·intellij-idea
春日见16 小时前
虚拟机上由于网络问题无法正常git clone
linux·服务器·网络·人工智能·git·ubuntu·debug
冉佳驹17 小时前
Linux ——— Git的核心操作流程、进程状态及环境变量相关知识
linux·git·进程·环境变量·进程状态·fork
cherry有点甜·17 小时前
【git】git为什么会出现双向合并
git
笨鸟不是菜鸟18 小时前
gitignore文件如何添加忽略文件或文件夹
git
灰色人生qwer18 小时前
git add . 添加超长文件名报错了怎么办?
git·python·elasticsearch
星海拾遗1 天前
git rebase记录
大数据·git·elasticsearch