git 常用命令

 获取ssh(新设备或系统重装后,执行获取ssh并在github仓库设置里将新ssh添加进去,就可以直接通过ssh克隆了)

$ ssh-keygen -t rsa -C "xxx@hotmail.com"

 

用户验证,通常首次提交需要验证

$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"

 

提交仓库常用几行代码

①$ git init 
②$ git add . 
③$ git commit -m "first commit" 
④$ git remote add origin https://github.com/yourName/yourRepo.git 
⑤$ git push -u origin master 

 

 错误提示:远程仓库已有工作内容。。。,提交失败,可以强制提交(记得这个好像是换了设备提交到同一仓库时,会出现)

$ git push -f origin master

 

使用Git克隆仓库分支 

$ git clone -b 分支名称 https://github.com/xxxxx/xxxxx.git

 

新建分支

$ git branch -b 分支名称

 

提交到分支

$ git push origin 分支名称

切换到分支

$ git checkout -b 分支名称

 

 

 

posted @ 2019-10-29 16:19  singhwong  阅读(86)  评论(0编辑  收藏  举报