[gitHub实践] git基础:远程仓库的使用

[gitHub实践] git基础:远程仓库的使用

版权2019.6.2更新

  • git 基础

    1. 远程仓库的使用

      • git remote

        # 查看远程仓库
        $ git remote # 克隆的仓库服务器默认名字
        origin # origin起源
        $ git remote -v # 读写远程仓库git保存的简写与其对应的URL
        origin  https://github.com/pengwill/eduSystem.git (fetch) # fetch取得
        origin  https://github.com/pengwill/eduSystem.git (push)
        
        # 添加远程仓库
        $ git remote add <shortname> <url>
        
      • git fetch [remote-name]

        # 从远程仓库中抓取与拉取
        # git fetch origin 会抓取新推送的所有工作,不会合并或者修改当前工作
        
        # git pull 自动抓取远程分支到当前分支,git clone 命令会自动设置本地master分支跟踪克隆的远程仓库master分支。
        
      • git push [remote-name] [branch-name]

        # 推送到远程仓库
        # 多人合作时,要求先拉取合并,再推送
        
      • git remote show [remote-name]

        # 查看远程仓库(更多信息)
        $ git remote show
        origin
        $ git remote show origin
        * remote origin
          Fetch URL: https://github.com/pengwill/eduSystem.git
          Push  URL: https://github.com/pengwill/eduSystem.git
          HEAD branch: master
          Remote branches:
            cfj    tracked
            dev_tp tracked
            master tracked
          Local branch configured for 'git pull':
            master merges with remote master
          Local ref configured for 'git push':
            master pushes to master (local out of date)
        
      • git remote rename

        # 重命名远程仓库的简写名
        $ git remote rename old new
        
      • git remote rm

        # 移除远程仓库
        $ git remote rm new
        

|版权声明:除特别注明外,本博客所有文章均为博主T.P原创,转载请注明出处:https://www.cnblogs.com/tp0829/p/10963165.html

posted @ 2019-06-02 15:52  T.P  阅读(214)  评论(0编辑  收藏  举报