git环境切换、清空提交记录、tar强制回滚

本文详细介绍了在Git中进行全局和本地配置更改的操作,包括查看全局设置、设置gitee仓库凭证以及切换仓库并推送代码的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


一. git环境切换:

1.查看全局设置

$ Git config --global --list
credential.https://codeup.aliyun.com.provider=generic
user.name=biejiahao
user.email=xxxxxxxx@qq.com

3.Git 切换本地git设置

git config --global user.name "gitee仓库"
git config --global user.email "xxxxxxxx@qq.com"

4.切换仓库并推送

cd existing_git_repo
git remote add origin https://gitee.com/username/mes.git
git push -u origin "master"

二 git清空历史提交

# 确保当前在 master 分支
git checkout master

# 硬重置到空状态(删除所有提交)
git checkout --orphan temp-empty
git commit -m "初始空提交"
git branch -D master
git branch -m master
git push origin master --force

三 git根据tar强制回滚

#1 查看分支
git branch

#2 切换到master分支
git checkout master

#3 查看标签
git tag
v1.3.3
v1.3.4
v1.3.5

#4 查看某个标签的详情
git show v1.3.5
commit fb479960c0cec5549463ae123d70bdd72ccf6be7

#5 通过commit id回退
git reset --hard fb479960c0cec5549463ae123d70bdd72ccf6be7

#6 显示所有提交过的版本信息
git log

#7 查看所有分支的所有操作记录
git reflog

#8.强制提交

git push -f -u origin master

四、git lab初始化项目方法

git lab初始化项目

选用其中一种方式创建:


第一种:全局设置git账号,但对于已经和git相连的似乎不起作用
Git global setup:
git config --global user.name "biejh"
git config --global user.email "biejh1497@xxxxxx.com"
第二种:创建一个新的仓库
Create a new repository:
git clone http://172.xx.xx.xx/biejh/wms.git
cd wms
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
第三种:已经存在一个项目文件
Existing folder:
cd existing_folder
git init
git remote add origin http://172.xx.xx.xx/biejh/wms.git
git add .
git commit -m "Initial commit"
git push -u origin master
第四种:已经存在一个git仓库
Existing Git repository:
cd existing_repo
git remote rename origin old-origin
git remote add origin http://172.xx.xx.xx/biejh/wms.git
git push -u origin --all
git push -u origin --tags
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值