【问题标题】:GIT commands to clone/create branch to a remote machine from another remote machine用于从另一台远程机器克隆/创建分支到远程机器的 GIT 命令
【发布时间】:2017-07-11 05:55:16
【问题描述】:

我想从我的 GIT 克隆一个 repo 到远程服务器,通过命令行我想创建一个分支并进行更改并将这个分支添加到 repo。我正在从我的系统访问该远程服务器 我使用了以下命令。

git clone <remote address of repo> <server local address>
cd <repository>
checkout <particular branch> or
checkout -b <new branch> under master
<<<<<<<made changes>>>>>>>>>>
now what ? to make these changes available to remote repository.

我有这个存储库可用。 现在创建分支并进行更改并将此分支添加到克隆的存储库中的正确顺序应该是什么。并创建拉取请求。

【问题讨论】:

  • 我不确定我是否理解正确。您是否在两个不同的 github 服务器(例如 github 服务和公司服务器)之间克隆存储库?我想你问的是本地存储库和远程它的标准 git 流,你可以阅读git-scm.com/book/en/v2/Git-Basics-Getting-a-Git-Repository
  • @HaimRaman 查看编辑。
  • 听起来像标准的 git 流。混帐添加。 git commit 和 git push?
  • 如果我想向某人发送拉取请求而不是 Push 怎么办

标签: git github


【解决方案1】:

git 依赖外部标准工具(例如ssh 或现有的 http 服务器)进行网络通信。

“在远程服务器上运行操作 git 操作”的标准方法很简单:

  • 登录远程服务器(例如:使用 ssh)
  • 运行操作

例如:

  • 在远程主机上创建 repo 的克隆:

    local$ ssh remote
    remote> cd /target/directory/
    remote> git clone ssh://local/repo  # <- or whatever url accessible from remote
    
  • 检查给定的提交:

    # interactively :
    local$ ssh remote
    remote> cd /target/directory/repo && git checkout [branch]
    
    # batch mode :
    local$ ssh remote 'cd /target/directory/repo && git checkout [branch]'
    
  • 拉取更改:

    # interactively :
    local$ ssh remote
    remote> cd /target/directory/repo && git pull
    
    # batch mode :
    local$ ssh remote 'cd /target/directory/repo && git pull'
    
  • 等等……

【讨论】:

  • 是的,我正在访问 thoruhg ssh。我不确定 git checkout [commit] 做了什么。 "去分支并提交?
  • @Hima 是的。准确地说:git checkout branch/tag/commitHEAD 移动到命名的提交(分支和标签只是提交的标签)并从提交中的树更新工作树中的文件。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-05-17
  • 2016-05-02
  • 2011-06-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多