关于git:测试开发之源码篇Git常用命令整理

3次阅读

共计 699 个字符,预计需要花费 2 分钟才能阅读完成。

根本命令

# 全局设置
git config --global user.name "aaronchen2k"
git config --global user.email "462826@qq.com"

# 克隆代码
git clone https://gitee.com/ngtesting/ci_test_pytest.git

# 参看本地分支
git branch   
# 查看近程分支 
git branch -r 

# 增加文件到版本库
git add test.txt

# 提交文件到版本库
git commit -m "update files"

# 推送文件到近程仓库
git push

分支操作

# 参看分支状态
git branch -v

# 创立分支
git branch v1.0

# 切换分支
git checkout v1.0

# 删除分支
git branch --delete v1.0

拉取近程代码

# 从近程获取代码,并合并到本地工作目录
git pull

# 获取近程仓库变更到到本地仓库,不合并当代码到前工作目录
git fetch

近程仓库

# 查看近程仓库
git remote -v

# 增加近程库
git remote add github https://github.com/aaronchen2k/ci_test_git.git

# 删除近程仓库
git remote rm github

# 推送到指定近程仓库
git push github

强制命令

# 强制笼罩近程
git push origin master --force

# 强制笼罩本地
git fetch --all
git reset --hard origin/main
git pull 

# 强制笼罩本地,单行
git fetch --all; git reset --hard origin/main; git pull 

专题目录

正文完
 0