了解Git以及如何使用EGit(git eclipse插件)
我刚刚开始从事一个使用 git 作为存储库的项目。实际上,我以前从未使用过版本控制系统,因为我是一个开发团队。 据我了解,如果您创建本地存储库的分支,请在 elcipse & 中选择该分支。然后更改代码。然后您应该能够选择原始的 master 分支 &如果您没有合并,您就不会看到这些更改。
让我感到困惑的是,当我切换回主分支时,我在新分支中所做的更改就在那里......即使我还没有合并。
我显然误解了整件事......任何想法 谢谢。
I just started working on a project that uses git as a repository. I've actually never used a version control system before as I'm a devloper team of one.
From what I understand if you create a branch of a local repository, select that branch in elcipse & then make changes to the code. You should then be able to select the original master branch & you wouldn't then see those changes provided you hadn't merged.
What's confusing me is that when I switch back to the master the changes I made in the new branch are in there...even though I haven't merged.
I'm obviously misunderstanding the whole thing....any ideaS'S
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为学习 Git 的一个很好的资源是 Pro Git。这是一本书,但你可以在线阅读。第一章教您有关版本控制和 git 基础知识的基础知识。
另外,请检查这个问题,其中列出了一些 git 教程。
即使您正在寻找快速入门指南,我也鼓励您花时间至少阅读 Pro Git 的前三章。这将使您对如何使用版本控制系统、一些 git 基础知识以及分支和合并的强大功能有一个很好的总体了解。然后查看我发布的第二个链接上的教程。
关于 egit,在其官方网站上有一些文档。一旦你掌握了 git,学习如何使用 egit 就会更容易。
I think a great resource for learning Git is Pro Git. It's a book, but you can read it online. The first chapters teach you the basics on Version Control and git basics.
Also, check this question, where some git tutorials are listed.
Even if you are looking for a quick start guide, I encourage you to take the time to read at least the first three chapters of Pro Git. This will give you a good general understanding of how to use a version control system, some git basics, and the power of branching and merging. Then check out the tutorials on the second link I posted.
Regarding egit, there's some documentation on its official site. Once you get the hand on git, it will be easier to learn how to use egit.
您没有明确地说出这一点,但我的猜测是您没有提交这些更改。 Git 很乐意让您在具有未提交更改的分支之间切换 - 只要这些更改不在两个分支之间不同的任何文件中。这有很大帮助的是,当您即将提交并发现签出了错误的分支时。
如果您提交了更改,然后切换了分支,您会看到它们完全按照您的预期消失。
(顺便说一句,合并是基于提交的操作 - 您合并两个(通常)提交并创建一个新的提交,其中原始两个提交都作为父级。考虑合并未提交的更改是没有意义的。
)要学习使用,更重要的是理解 Git,有很多很棒的参考资料 - 例如 Git Parable(轻松地介绍核心思想),ProGit 和 Git 社区书籍。原则上,EGit 是一件很棒的事情,它使事情可以通过 IDE 进行访问 - 但我提醒您不要忽略对事情在幕后如何真正工作的良好理解。有一天,它可能会让您免于点击按钮然后说“哦,不,我做了什么!”
You didn't explicitly say this, but my guess is that you didn't commit those changes. Git will happily let you switch between branches with uncommitted changes - as long as those changes aren't in any files which differ between the two branches. The big thing that this helps with is when you're about to commit and discover you have the wrong branch checked out.
If you committed your changes, then switched branches, you'd see them disappear exactly as you expect.
(And merges, by the way, are commit-based operations - you merge two (generally) commits and create a new commit with both of the original two as parents. It makes no sense to think about merging with uncommitted changes.)
With respect to learning to use, and more importantly understanding Git, there are a lot of great references out there - for example the Git Parable (lighthearted introduction to the core ideas), ProGit and the Git Community Book. EGit is a great thing in principle, making things accessible through an IDE - but I'd caution you not to skip over a good understanding of how things are really working under the hood. It'll probably save you someday from clicking on a button then saying "oh no, what have I done!"
关于 Egit,我会推荐 ekke 的角文章:
“关于我的安装和使用经验的博客系列集成在 Eclipse 中的分布式版本控制系统”
Regarding Egit, I would recommend ekke's corner articles:
"Blog series about my experiences to install and use a Distributed Version Control System integrated in Eclipse"