查看有哪些远程仓库
git remote
appledeMacBook-Pro-2:git教程 apple$ git remote
origin
yynew
查看远程仓库
git remote -v appledeMacBook-Pro-2:git教程 apple$ git remote -v
origin ssh://git@dev.****.com.cn:222/yueyin/mylab.git (fetch)
origin ssh://git@dev.****.com.cn:222/yueyin/mylab.git (push)
yynew ssh://git@dev.****.com.cn:222/yueyin/yytopc.git (fetch)
yynew ssh://git@dev.****.com.cn:222/yueyin/yytopc.git (push)
查看远程仓库信息
appledeMacBook-Pro-2:git教程 apple$ git remote show yynew
* remote yynew
Fetch URL: ssh://git@dev.****.com.cn:222/yueyin/yytopc.git
Push URL: ssh://git@dev.****.com.cn:222/yueyin/yytopc.git
HEAD branch: master
Remote branches:
1- tracked
1-crawl tracked
master tracked
Local ref configured for 'git push':
master pushes to master (up to date)
添加远程仓库
git remote add [remote-name] [url]
appledeMacBook-Pro-2:git教程 apple$ git remote add yynew ssh://git@dev.*****.com.cn:222/yueyin/yytopc.git//这一句是添加
appledeMacBook-Pro-2:git教程 apple$ git remote -v//添加之后查询远程仓库
origin ssh://git@dev.*****.com.cn:222/yueyin/mylab.git (fetch)
origin ssh://git@dev.*****.com.cn:222/yueyin/mylab.git (push)
yynew ssh://git@dev.*****.com.cn:222/yueyin/yytopc.git (fetch)
yynew ssh://git@dev.*****.com.cn:222/yueyin/yytopc.git (push)
删除远程仓库
appledeMacBook-Pro-2:git教程 apple$ git remote rm yynew
appledeMacBook-Pro-2:git教程 apple$ gir remote
-bash: gir: command not found
appledeMacBook-Pro-2:git教程 apple$ git remote
origin
修改远程仓库
git remote set-url --push [remote-name] [newUrl]
重命名远程仓库
git remote rename <old-remote-name> <new-remote-name>
从远程仓库获取数据
git fetch [remote-name]
appledeMacBook-Pro-2:git教程 apple$ git fetch yynew
warning: no common commits
remote: Counting objects: 2157, done.
remote: Compressing objects: 100% (702/702), done.
remote: Total 2157 (delta 1389), reused 2152 (delta 1389)
Receiving objects: 100% (2157/2157), 77.02 MiB | 704.00 KiB/s, done.
Resolving deltas: 100% (1389/1389), done.
From ssh://dev.******.com.cn:222/yueyin/yytopc
* [new branch] 1- -> yynew/1-
* [new branch] 1-crawl -> yynew/1-crawl
* [new branch] master -> yynew/master
**拉取远程仓库到本地分支
git pull [remote-name] [本地分支名]
**
注:这一次操作是在你从远程仓库中获取到数据以后和本地的分支合并,在合并之前你的项目不会变
appledeMacBook-Pro-2:git教程 apple$ git pull yynew master
From ssh://dev.*****.com.cn:222/yueyin/yytopc
* branch master -> FETCH_HEAD
Merge made by the 'recursive' strategy.
README.md | 0
yy.sql
推送到远程仓库
git push [remote-name] [本地分支名]
推送之后就可以在你的远程项目中查看你的更新内容了