一、创建远程仓库

1,在GitHub上创建一个远程仓库(前提是要注册一个GitHub账号),如图所示。

Git添加远程仓库

Git添加远程仓库

Git添加远程仓库

二、配置远程仓库并向远程推送文件

1,用命令“git config user.name yourname”配置name,“git config user.email youremail”配置邮箱。

2,用“git remote add origin https://github.com/lcgzyd/learn.git”关联远程仓库,值得注意的是后面的地址(https://github.com/lcgzyd/learn.git)需要换成自己的地址。

3,用“git push -u origin master”第一次推送master的所有内容,以后每次推送只需用“git push origin master”即可。

Git添加远程仓库

4,“git clone https://github.com/lcgzyd/learn.git”命令是将远程仓库的文件下载到本地,如图所示。

Git添加远程仓库

三、创建分支、合并分支

“git checkout -b dev”创建一个dev分支并切换到dev分支

“git branch”列出分支

“git checkout master”切换到master分支

“git meger dev”合并dev分支

“git branch -d dev”删除dev分支

相关文章:

  • 2022-01-01
  • 2021-10-08
  • 2021-06-28
  • 2021-10-12
  • 2021-10-20
  • 2021-04-07
  • 2021-12-05
  • 2021-11-18
猜你喜欢
  • 2021-09-24
  • 2021-11-02
  • 2021-05-31
  • 2022-01-20
  • 2021-09-29
  • 2021-07-06
  • 2021-11-18
相关资源
相似解决方案