git-远程仓库的使用

查看有哪些远程仓库
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] [本地分支名]

推送之后就可以在你的远程项目中查看你的更新内容了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值