1. 新建远程仓库
登录github新建一个远程仓库
2. 将远程仓库clone下来
git clone github仓库地址
如果不这样,后面push时会出错,因为本地和远程不关联
3. 将本地仓库与之关联
git remote add pb https://github.com/paulboone/ticgit
//pb是名字
//后面是github上的仓库网址
4. 提交
git push -u pb master
把本地库的内容推送到远程,用git push命令,实际上是把当前分支master推送到远程。
由于远程库是空的,我们第一次推送master分支时,加上了-u参数,Git不但会把本地的master分支内容推送的远程新的master分支,还会把本地的master分支和远程的master分支关联起来,在以后的推送或者拉取时就可以简化命令。
5. 移除本地与远程仓库的关联
$ git remote rm pb
//pb 是名字
这个只是拓展,不是必须执行