远程仓库

添加一个远程仓库

$ git remote add <local-name> <server>

比如:

$ git remote add origin /root/git-test/

此时在本地仓库命名了一个叫 origin 的远程仓库,之后只需要使用此名称就可将变更推送到指定远程仓库。

查看 git 配置文件可以看到添加成功了:

$ cd .git && cat config
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	url = /root/git-test/
	fetch = +refs/heads/*:refs/remotes/origin/*

查看远程仓库信息

$ git remote show origin
* remote origin
  Fetch URL: https://gitee.com/quanzaiyu/quanzaiyu.git
  Push  URL: https://gitee.com/quanzaiyu/quanzaiyu.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)

重命名远程仓库的名字

$ git remote rename <originName> <targetName>

删除远程仓库

$ git remote rm origin

MIT Licensed | Copyright © 2018-present 滇ICP备16006294号

Design by Quanzaiyu | Power by VuePress