Git Repo 设置在本地分支上工作

发布于 2024-12-15 03:38:39 字数 314 浏览 3 评论 0原文

我有一个回购设置,并且正在学习分支如何工作。现在我在远程仓库上有两个分支: 掌握 dev

在 git 和 svn 之间使用相同的单词 checkout 有点令人困惑,因为在 svn 中这意味着拉取所有文件,但在 git 中它仅意味着切换提交的位置。

在创建 dev 分支之前,我尝试过 git clone ,但是当我尝试从本地计算机推送时,它给了我一条消息,说它不会这样做,因为如果我这样做,索引和树会变得混乱。

我想在本地计算机上进行开发工作,并可能将其与主分支进行比较。 git clone 并没有拉下 dev 分支,只拉下了 master 分支。我该怎么做呢?

I have a repo setup, and am just learning about how branches work. Right now I have two branches on the remote repo:
master
dev

It's a little bit confusing to have the same word checkout between git and svn, since in svn it means pull all the files, but in git it only means switch where the commits will go.

I tried to git clone before I created the dev branch, but when I tried to push from my local machine it gave me a message saying it wouldn't do it due to the index and tree getting messed up if I did it.

I want to work on dev on my local machine, and possibly diff and compare that to the master branch. git clone didn't pull down the dev branch, only the master one. How should I go about doing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

别想她 2024-12-22 03:38:39

实际上,git clone 确实获取了 master 分支并检查了它。您现在可以使用 git checkout --track -b dev origin/dev 签出 dev 分支(从远程 origin 签出分支 dev ,并创建一个名为 dev 的新(本地)分支来跟踪它)。

Actually, git clone did fetch the master branch and check it out. You can now checkout the dev branch using git checkout --track -b dev origin/dev (checkout the branch dev from the remote origin, and create a new (local) branch called dev that tracks it).

陌伤ぢ 2024-12-22 03:38:39

您只需要存储库的一个克隆即可完成您要查找的操作。当您在开发分支中工作时,您可以将您的更改与任何其他分支进行比较。例如,要显示 dev 和 master 之间的更改的简单列表,您可以在 dev 分支中执行以下操作:

git diff --stat master

如果您想查看两者之间的实际更改,您可以执行以下操作:

git diff master

很多命令将允许您传递分支名称执行此类功能。

You only need one clone of the repo to do what you are looking for. While you are working in the dev branch you can compare your changes with any other branch. For example to show a simple list of changes between dev and master you could do while in the dev branch:

git diff --stat master

If you want to see the actual changes between the two you can do:

git diff master

A lot of the commands will allow you to pass in branch names to do this type of functionality.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文