git基础操作

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

  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值