如何查看/编辑 git 远程分支
嗨,我对 git 完全陌生,但我有使用 SVN 的经验。所有教程都假设人们知道如何在使用 git 时查看/编辑文件,但我很困惑。我克隆了一个存储库(来自需要与我共享代码的人),然后将几个远程分支签出到本地分支。现在我想查看代码(它是Java)。我在文件系统上的任何位置都找不到这些文件。从命令行,它只提供不同提交的差异。我对此不感兴趣!我只想查看最新版本的代码,最好是在 Eclipse 中。但此时我很乐意在 gedit 中打开它。帮助!
非常感谢!
Hi I'm completely new to git, but I have experience with SVN. All the tutorials assume that one knows how to view/edit a file when using git, but I'm confused. I cloned a repository (from someone who needed to share code with me), then checked out several remote branches to local branches. Now I want view the code (it's Java). I can't find the files anywhere on my file system. From the command line, it only gives me the diffs for different commits. I'm not interested in that! I just want to see the latest edition of the code, preferably in Eclipse. But at this point I would be happy to open it in gedit. Help!
Thank you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果在文件系统中找不到任何文件,则可能是使用
--bare
选项克隆了存储库。您可以再次克隆存储库,但不需要--bare
。If you cannot find any files in file system, it is possible that the repository is cloned with
--bare
option. You can clone the repository again, but without--bare
.首先,这里有一些有用的通用资源。这是一个很好的、简短的 git 教程。
http://www.eecs.harvard.edu/~cduan/technical/git /
本 Mercurial 教程的第 0 章对于从 svn 迁移到 git 的人来说就像从 svn 迁移到 hg 一样有效。仅阅读本章,并将任何提及的 Mercurial 替换为 Git。
http://hginit.com/top/00.html
确保您正确克隆了存储库。我假设我们是在您的主目录中执行此操作。
您现在应该有一个文件夹
~/foo
。这是您的工作副本。在foo
中,您将找到一个文件夹.git
。.git
保存您的本地存储库。要查看项目的最新版本,请运行这些命令。Git 会将
~/foo
中的文件更新为存储库中的最新版本。阅读我在本文开头提供的链接,了解如何浏览 git 存储库。First, here are a couple helpful general resources. Here's a good, short git tutorial.
http://www.eecs.harvard.edu/~cduan/technical/git/
Chapter 0 of this Mercurial tutorial works just as well for someone moving from svn to git as svn to hg. Only read this chapter, and replace any mention of Mercurial with Git.
http://hginit.com/top/00.html
Make sure you cloned the repository correctly. I'll pretend we're doing this in your home directory.
You should now have a folder
~/foo
. This is your working copy. Insidefoo
you will find a folder.git
..git
holds your local repository. To see the most up to date version of the project, run these commands.Git will update the files in
~/foo
to the most recent version in the repository. Read the links I gave you at the beginning of this post to learn how to navigate around the git repository.