1、在gitlab创建上一个测试仓库,用于平时测试使用
项目名称为: test
2、在本地拉取仓库并创建分支test1
git clone https://gitlab.ge.cn/renyh/test.git
cd test
git checkout -b test1 创建并切换分支
3、查看git配置信息
git config --list 查看所有配置信息
参数–global 全局范围内查看git的配置项
修改配置信息:
命令行配置用户名 : git config --global user.name "用户名"
命令行配置邮箱 : git config --global user.email "邮箱"
4、修改README.md并提交到远程仓库
git add README.md 将工作区添加到暂存区
➜ test git:(test1) ✗ git commit -m "modified README.md" 提交暂存区到本地仓库
[test1 41fd941] modified README.md
1 file changed, 2 insertions(+), 1 deletion(-)
➜ test git:(test1) git push origin test1 提交到远程仓库
5、添加文件file1,内容随便,并提交到远程仓库
➜ test git:(test1) vim file1
➜ test git:(test1) ✗ git add file1
➜ test git:(test1) ✗ git commit -m "add file1"
[test1 99133cf] add file1
sfdgnhds vf
1 file changed, 2 insertions(+)
create mode 100644 file1
➜ test git:(test1) git push origin test1
6、创建一个新的分支,创建文件并提交到远程仓库
➜ test git:(test1) git checkout -b ryh
Switched to a new branch 'ryh'
➜ test git:(ryh) vim file2
➜ test git:(ryh) ✗ git add file2
➜ test git:(ryh) ✗ ls
README.md file1 file2
➜ test git:(ryh) ✗ git commit -m "add file2"
\[ryh db49996] add file2
1 file changed, 1 insertion(+)
create mode 100644 file2
➜ test git:(ryh) git push origin ryh
结果:新建的分支,还是在一条路线上,没有岔
7、删除分支ryh
# 删除本地分支
git branch -d ryh
# 如果本地分支有未合并的更改,强制删除
git branch -D ryh
# 删除远程仓库的分支
git push origin --delete ryh