how to view/edit a git remote branch
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!
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 clone <repository>
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.
cd ~
git clone git://url.to.remote.repository.com/foo.git
You should now have a folder ~/foo
. This is your working copy. Inside foo
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.
cd ~/foo
git checkout master
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.
精彩评论