远程仓库
创建SSH Key
1 | $ ssh-keygen -t rsa -C "youremail@example.com" |
关联远程仓库
1 | git remote add origin git@github.com:git_username/repository_name.git |
添加后,远程库的名字就是origin
取消关联远程库
1 | git remote remove origin |
查看远程库
1 | git remote |
查看远程库详细信息
如果没有相关权限,则看不到相关地址信息
例如没有推送权限,则看不到push地址
1 | git remote -v |
推送到远程仓库
1 | $ git push origin <branch-name> |
-u
表示第一次推送master分支的所有内容,不过建议先clone在push,尽量避免此方法
1 | $ git push -u origin <branch-name> |
日常提交只需要使用git push
即可
从远程克隆
1 | $ git clone https://github.com/usern/repositoryname.git |
日常获取只需要使用git pull
即可