Git小结

注册账号以及创建仓库
1.注册账号:https://github.com/
2.Create a New Repository,创建一个新的仓库

安装git for window 及使用
1.安装完成之后,Git Bash 打开git命令行,
2.生成ssh key

  1. $ ssh-keygen -t rsa -"youremail.com"
复制代码

youremail.com改为你在github上注册的邮箱,之后会要求确认路径和输入密码,我们这使用默认的一路回车就行。成功的话会在~/下生成.ssh文件夹,进去打开id_rsa.pub,复制里面的key。
回到github上,进入Your Profile(账户配置),左边选择SSH and GPG keys,Add SSH Key,title随便填,粘贴在你电脑上生成的key。

3.验证是否成功

  1. $ ssh -T git@github.com 
复制代码

如果是第一次的会提示是否continue,输入yes就会看到:You've successfully authenticated, but GitHub does not provide shell access 。这就表示已成功连上 github。 
4.设置username和email

  1. $ git config --global user.name "your name"
复制代码
  1. $ git config --global user.email "your_email@youremail.com"
复制代码

5.配置远程地址

  1. git remote add origin git@github.com:github账号/仓库名.git
复制代码

加完之后进入.git,打开config,这里会多出一个remote "origin"内容,这就是刚才添加的远程地址,也可以直接修改config来配置远程地址。 

大致流程
1.使用git clone https://github.com/xxxxxxx/xxxxx.git克隆到本地
2.git pull --rebase origin master 更新
3.git add . (将改动添加到暂存区)
4.git commit -m "提交说明"
5.git push origin master 将本地更改推送到远程master分支。

posted @ 2019-06-19 11:09  死神敲键  阅读(103)  评论(0编辑  收藏  举报