文章目录
一. 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