我应该如何使用 git 分支?

发布于 2024-10-07 21:37:12 字数 302 浏览 0 评论 0原文

git 新手。从概念上讲,对其中一些如何工作有点困惑。

因此,就本地工作而言,建立一个仅包含投入生产的分支和另一个用于测试想法等的分支是个好主意,然后我可以将其合并。是否像创建这些分支一样简单,然后当我不希望将项目的任何最新更改提交到主分支时,我只需切换到“测试”分支并从那里提交/推送?我只是对本地项目活动和 git 之间的交互感到困惑。

比如说,我向我的 android 项目添加一些代码并保存,除非我提交,否则这些更改不会对主存储库产生影响?即使就实际的本地项目而言,情况也是如此,这些更改已保存。

我这样想对吗?如果没有,请让我直面?

New to git. A bit confused about how some of it works, conceptually.

So it sounds like, in terms of local work, its a good idea to have a branch that contains only what goes into production and another for testing out ideas, etc. which I can then merge. Is it as simple as creating those branches and then when I don't want any recent changes to my project to be committed to the master branch, I just switch to the "testing" branch and commit/push from there? I'm just confused about the interaction between local project activity and git.

Say, for example, I add some code to my android project and save, those changes will have no effect on master repo unless I commit? And that's the case even though, in terms of the actual local project, those changes were saved.

Am I thinking about this right? If not, set me straight?

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

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

发布评论

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

评论(2

疯狂的代价 2024-10-14 21:37:12

例如,我添加一些代码
我的android项目并保存,那些
更改不会对 master 产生影响
除非我提交,否则回购?这就是
即使如此,就
实际的本地项目,这些变化
被拯救了。

实际上,在您推送之前,他们不会更改主存储库中的任何内容。
当您提交时,它会更改您的本地存储库。

这实际上取决于您想要如何组织分支(实际上取决于您同时工作的数量),但是您始终可以拥有这些分支,并致力于它们,并且当您有一致的东西时,您始终可以创建一个要合并的新分支,使用cherry-pick和/或rebase -i使其成为一系列干净的提交并合并/推送该分支。

Say, for example, I add some code to
my android project and save, those
changes will have no effect on master
repo unless I commit? And that's the
case even though, in terms of the
actual local project, those changes
were saved.

Actually they won't change anything in the master repo until you push.
It will change your local repo when you commit.

It's really up to you how you want to organize your branches (really depends on how many things you work at the same time), but you can always have those branches, commit to them and when you have something consistent, you can always create a new branch of things to merge, use cherry-pick and/or rebase -i to make it a clean serie of commits and merge/push that branch.

亚希 2024-10-14 21:37:12

git 的创建者 Linux Torvalds 三年前在 Google 上发表了关于 Git 的演讲:http://www .youtube.com/watch?v=4XpnKHJAok8

Git Wiki 页面:https:/ /git.wiki.kernel.org/index.php/Main_Page

Creator of git, Linux Torvalds, gave a speech 3 years ago at Google on Git: http://www.youtube.com/watch?v=4XpnKHJAok8

Git Wiki page: https://git.wiki.kernel.org/index.php/Main_Page

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