标签:没有 pru http project 合作 connect 远程仓库 分支 ESS
git remote
命令,它会列出你指定的每一个远程服务器的名称$ git clone https://github.com/schacon/ticgit Cloning into ‘ticgit‘... remote: Reusing existing pack: 1857, done. remote: Total 1857 (delta 0), reused 0 (delta 0) Receiving objects: 100% (1857/1857), 374.35 KiB | 268.00 KiB/s, done. Resolving deltas: 100% (772/772), done. Checking connectivity... done. $ cd ticgit $ git remote origin
会显示需要读写远程仓库使用的 Git 的 URL和名称(origin)
git remote -v origin https://github.com/schacon/ticgit (fetch) origin https://github.com/schacon/ticgit (push)
$ cd grit $ git remote -v bakkdoor https://github.com/bakkdoor/grit (fetch) bakkdoor https://github.com/bakkdoor/grit (push) cho45 https://github.com/cho45/grit (fetch) cho45 https://github.com/cho45/grit (push) defunkt https://github.com/defunkt/grit (fetch) defunkt https://github.com/defunkt/grit (push) koke git://github.com/koke/grit.git (fetch) koke git://github.com/koke/grit.git (push) origin git@github.com:mojombo/grit.git (fetch) origin git@github.com:mojombo/grit.git (push)
git remote add <shortname> <url>
添加一个新的远程 Git 仓库,同时指定一个名称
polo@B-J5D1MD6R-2312 watermarker % git remote -v origin git@gitee.com:poloyy/watermarker.git (fetch) origin git@gitee.com:poloyy/watermarker.git (push) polo@B-J5D1MD6R-2312 watermarker % git remote add test git@gitee.com:testyy/waterm arker.git polo@B-J5D1MD6R-2312 watermarker % git remote -v origin git@gitee.com:poloyy/watermarker.git (fetch) origin git@gitee.com:poloyy/watermarker.git (push) test git@gitee.com:testyy/watermarker.git (fetch) test git@gitee.com:testyy/watermarker.git (push)
可以使用 test
来代替整个 URL
可以运行 git fetch pb,拉取仓库数
据
$ git fetch pb remote: Counting objects: 43, done. remote: Compressing objects: 100% (36/36), done. remote: Total 43 (delta 10), reused 31 (delta 5) Unpacking objects: 100% (43/43), done. From https://github.com/paulboone/ticgit * [new branch] master -> pb/master * [new branch] ticgit -> pb/ticgit
从远程仓库中获得数据,可以执行
git fetch <remote>
git clone 命令克隆了一个仓库,Git 会自动将其添加为远程仓库并默认以 “origin” 为名称
git fetch origin
git clone
命令会自动设置本地 master 分支跟踪 clone 下来的远程仓库的 master
分支(或其它名字的默认分支)git pull
通常会从最初克隆的服务器上抓取数据并自动尝试合并到当前所在的分支
git push <remote> <branch>
将 master 分支的内容推送到 origin 服务器
git push origin master
remote 默认就是 origin,而 branch 默认是 master,所以等价写法就是
git push
如果在你推送前,远程仓库已经有新推送的内容,那么本地需要先拉取最新的内容并合并后,才能将本地的内容重新 push 到远程仓库
# 一般的流程 git fetch git pull git add . git commit -m "update" git push
git remote show <remote>
可以查看远程仓库的更多信息
% git remote show origin * 远程 origin 获取地址:git@gitee.com:poloyy/watermarker.git 推送地址:git@gitee.com:poloyy/watermarker.git HEAD 分支:master 远程分支: master 已跟踪 为 ‘git pull‘ 配置的本地分支: master 与远程 master 合并 为 ‘git push‘ 配置的本地引用: master 推送至 master (可快进)
$ git remote show origin * remote origin URL: https://github.com/my-org/complex-project Fetch URL: https://github.com/my-org/complex-project Push URL: https://github.com/my-org/complex-project HEAD branch: master Remote branches: master tracked dev-branch tracked markdown-strip tracked issue-43 new (next fetch will store in remotes/origin) issue-45 new (next fetch will store in remotes/origin) refs/remotes/origin/issue-11 stale (use ‘git remote prune‘ to remove) Local branches configured for ‘git pull‘: dev-branch merges with remote dev-branch master merges with remote master Local refs configured for ‘git push‘: dev-branch pushes to dev-branch (up to date) markdown-strip pushes to markdown-strip (up to date) master pushes to master (up to date)
包含多个分支的信息
git remote rename <old> <new>
$ git remote rename pb paul
$ git remote
origin
paul
同时会修改你所有远程跟踪的分支名字,之前引用 pb/master
的现在会引用 paul/master
git remote remove paul
$ git remote
origin
重点:一旦以这种方式删除了一个远程仓库,那么所有和这个远程仓库相关的远程跟踪分支以及配置信息也会一起被删除
标签:没有 pru http project 合作 connect 远程仓库 分支 ESS
原文地址:https://www.cnblogs.com/poloyy/p/14773796.html