概述:
作为程序员最自豪就是和大牛一起写项目,但是Git就是团队协作的仓库,必须要了解仓库操作
1.查看远程仓库
语法: git remote
$ git remote
origin
Administrator@USER-20170424ZG MINGW64 ~/grit (master)
$ git clone https://github.com/schacon/ticgit
Cloning into 'ticgit'...
remote: Counting objects: 1857, done.
remote: Total 1857 (delta 0), reused 0 (delta 0), pack-reused 1857
Receiving objects: 100% (1857/1857), 331.41 KiB | 169.00 KiB/s, done.
Resolving deltas: 100% (837/837), done.
Administrator@USER-20170424ZG MINGW64 ~/grit (master)
$ cd ticgit
Administrator@USER-20170424ZG MINGW64 ~/grit/ticgit (master)
$ git remote
origin
Administrator@USER-20170424ZG MINGW64 ~/grit/ticgit (master)
$ git remote -v
origin https://github.com/schacon/ticgit (fetch)
origin https://github.com/schacon/ticgit (push)
第一:git remote 显式 origin(这是Git给你克隆的仓库服务器的默认名字) (我已经克隆过一个自己的仓库)
第二:git clone 网址 ( 克隆网上的项目)
第三:切换 ticgit目录
第四:git remote 显式origin
第五:git remote -v (显式服务器的简称和网址)
2.添加远程仓库
语法:
git remote add 服务器名 网址 (其实就是将服务器名=网址上)
git remote add newService https://github.com/paulboone/ticgit
Administrator@USER-20170424ZG MINGW64 ~/grit (master)
$ git fetch newService
remote: Counting objects: 634, done.
remote: Total 634 (delta 0), reused 0 (delta 0), pack-reused 634
Receiving objects: 100% (634/634), 88.92 KiB | 55.00 KiB/s, done.
Resolving deltas: 100% (261/261), done.
From https://github.com/paulboone/ticgit
* [new branch] master -> newService/master
* [new branch] ticgit -> newService/ticgit
3.从远程仓库中抓取与拉取
语法:git fetch [remote-name]\
如上
4.推送到远程仓库
类似SVN的提交代码,如果别修改之后再你之前提交,你必须更新他提交的代码,再提交
语法: git push origin master
5.查看远程仓库
语法:git remote show 服务器名
$ git remote show newService
* remote newService
Fetch URL: https://github.com/paulboone/ticgit
Push URL: https://github.com/paulboone/ticgit
HEAD branch: master
Remote branches:
master tracked
ticgit tracked
Local ref configured for 'git push':
master pushes to master (local out of date)
6.远程仓库的移除和重命名
重命名的语法:git remote rename 旧仓库名 新仓库名
$ git remote rename newService service
Administrator@USER-20170424ZG MINGW64 ~/grit (master)
$ git remote
origin
service
移除的语法:git remote rm 仓库名
$ git remote rm service
Administrator@USER-20170424ZG MINGW64 ~/grit (master)
$ git remote
origin
总结:主要远程仓库的操作,具体工程进行实践