栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

linux git 操作

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

linux git 操作

linux git 操作 branch 操作

新建分支new_branch同步远程分支origin/xxx

git checkout -b 新分支名 origin/远程分支名

新分支同步到远程仓库

git push origin 新分支名

查看本地分支

git branch

查看远程分支

git branch -r

查看所有分支

git branch -a

拉取远程分支(如果不是origin,则需要换成对应的名称)

git remote update origin --prune

切换分支(不需要 origin)

git checkout 分支名

拉取当前分支代码

git pull origin 分支名

删除本地分支

git branch -d 分支名

删除远程分支

git push origin --delete 分支名

提交操作

将修改文件提交到暂缓区

git add 文件名

提交修改

git commit -m “First commit”

推送到远程库

git push origin maste

查看本地修改

git status

如果在远程服务器上有代码更新,直接丢弃所有更改的命令

git checkout ./

回滚提交(将当前branch的HEAD指针指向commit hash)

git reset --hard resetVersionHash

查询git提交版本的hash

git rev-list --max-count=2 HEAD

查询当前提交版本的hash

git rev-parse HEAD

分支合并

合并 分支 到本地分支

git merge 分支名

查看合并状态 并解决冲突

git status

将冲突文件提交至 暂缓区

git add 冲突文件

提交merge 后的结果

git commit -m “merge commit”

推送合并结果到远程库

git push origin 分支名

问题解决 git 冲突解决 needs merge error: you need to resolve your current index first

解决方案:本地回退到当前版本,不影响远程库

git reset --hard

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/882129.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号