GIT - 跟踪分支与克隆之间的区别 [英] GIT - Difference between tracking a branch versus cloning

查看:124
本文介绍了GIT - 跟踪分支与克隆之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



git checkout --track -b< ...>



如果我在远程服务器上创建裸露的回购站并在两个不同的位置工作,那么最快和批准的方式是什么所以我做的是,我在我的笔记本电脑上创建了初始回购,然后将更改推送到我的VPS回购(原始回购)的原点 。现在,在我的桌面上,我应该克隆我的回购?我问,因为我有两个分支,开发人员和主人。一旦我在我的桌面上,我不确定应该追踪回购,还是应该先克隆?如果我想在开发分支上工作会怎么样?当我使用--track指令签出时,该怎么办?



这是我迄今为止所做的。



在笔记本电脑上

  cd devproject 
git init
git add。
git commit -m我的第一个提交

关于VPS回购

  mkdir /home/sam/devproject.git 
cd /home/sam/devproject.git
git --bare init
退出

返回便携式计算机

  cd devproject 
git remote add origin ssh://myserver.com/home/sam/devproject.git

在桌面上(??)

  git clone< ;. > 


解决方案

克隆存储库,但是跟踪分支。您发布的结帐命令尚未完成:

  git checkout --track -b new_local_branch_name origin / remote_branch_name 
code>

因此,所需的步骤是:


  1. 克隆远程仓库。

  2. 跟踪远程分支。


I've seen this command floating around on various sites.

git checkout --track -b <...>

If I create a bare repo on a remote server and work from two different locations, what is the quickest and "approved" way of doing so?

What I did was, I created the initial repo on my laptop and then pushed the changes to the "origin" where my VPS repo is (the bare repo). Now, on my desktop, should I be cloning my repo? I ask because I have two branches, "dev" and "master." Once I'm on my desktop, I wasn't sure if I should be "tracking" the repo or should I be cloning first? What if I wanted to work on the dev branch, is that when I checkout using the --track directive?

Here's what I've done so far.

On laptop

cd devproject
git init
git add .
git commit -m "My first commit"

On VPS Repo

mkdir /home/sam/devproject.git
cd /home/sam/devproject.git
git --bare init
exit

Back to laptop

cd devproject
git remote add origin ssh://myserver.com/home/sam/devproject.git

On Desktop (??)

git clone <..>

解决方案

You clone a repository, but you track a branch. The checkout command you posted is not complete:

git checkout --track -b new_local_branch_name origin/remote_branch_name

Thus the required steps would be:

  1. Clone the remote repository.
  2. Track the remote branches.

这篇关于GIT - 跟踪分支与克隆之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆