1、首先安装git和vs code
2、登录gitee账户,添加本电脑的ssh公钥;
打开本机的git终端,输入命令获取sshkey;
ssh-keygen -t rsa -C"xxxxx@xxxxx.com"
然后生成的ssh公钥默认会保存在~文件夹中,所以cd ~
然后cat.ssh/id_rsa.pub文件内容获取公钥粘贴到gitee上;
3、新建一个文件夹,然后输入命令:git init
去初始化一个git仓库
4、输入命令:git remote add hostname url(eg: git remote add origin git@github.com:michaelliao/learngit.git)
去连接远程仓库
5、拉取远程仓库代码到本地
git pull hostname branchname(eg: git pull orign master)
6、分支操作:
git branch -a
git branch 新分支名字
git switch 分支名字
7、推送代码到远程仓库
git status
git add filename
git add . (添加所有文件到stage暂存区)
git commit -m"本次提交的说明"
git push hostname branchname(eg: git push ori_mb master)(hostname指定了你要推向哪个远程仓库。这里指的ori_mb)
注意:一个电脑账户,如何创建多个git ssh密钥
https://www.cnblogs.com/dbave/p/11718492.html
注意:如果拉代码的时候,告诉
git@gitlab.com: Permission denied (publickey).
并不是说我们git没有找到相应地址的私钥,还有一种可能,我们的帐号并没有添加到这个项目的项目成员中,所以我们这个账号无法下载项目,找管理员把我们邮箱账号拉到项目里即可;