Jeffery Brewer (Tue, Aug 07, 2012 at 11:54:16AM -0700) >>
> So here's my current problem. I'm trying to "checkout" (not sure if that's 
> the right term or not) files from my repository into an existing folder (a 

Try to be careful with terminology.  It's made more confusing by the
fact that the same terms mean different things in different version
control systems, but in git "checkout" means, "Update files in the
working tree to match the version in the index or the specified
tree"[1], where "the specified tree" is usually a commit or branch ID.

Also, always bear in mind that in a DVCS like git *every clone* is a
repository.  So when you say "my repository" -- which repository do you
mean?  Do you mean a repository you've created on your local machine, a
repository you've cloned locally, or some "central" repository on a
server somewhere (say, github)?

If it is a local repository, it would be usual for there already to be a
working tree of the files checked out (unless you'd created a "bare"
repository which you are unlikely to have done accidentally).

> folder created as a NetBeans project...something NetBeans recognizes as a 
> project folder). Clone doesn't work...tells me there is existing content. 

Please describe what is the state of the repository and your working
folders and what it is you are trying to achieve (what state you are
trying to get them into).

It sounds as if you have a set of source files in a repository on a
server somewhere, and a folder locally-created by NetBeans with no
source but some sort of project files which NetBeans uses.  Assuming
this is the case, here is one approach.  In the following sequence of
commands, "$" represents the prompt, so shouldn't be copied.  Anything
without a $ represents the likely output, so obviously you don't copy
that either.  You should start in the parent folder of the netbeans
project.  Obviously you would need to replace the repository address
with your own.  Also I know nothing about NetBeans so I just pretended
for the sake of example that your netbeans project folder contains a
single file, "project.netbeans".  Hopefully all will become clear...

  $ ls
  $ git clone
  Cloning into 'project'...
  remote: Counting objects: 20, done.
  remote: Compressing objects: 100% (16/16), done.
  remote: Total 20 (delta 5), reused 19 (delta 4)
  Receiving objects: 100% (20/20), 16.21 KiB, done.
  Resolving deltas: 100% (5/5), done.
  $ ls
  netbeans_project project
  $ cp -rf netbeans_project/* project
  $ rm -rf netbeans_project
  $ cd project
  $ git status
  # On branch master
  # Untracked files:
  #   (use "git add <file>..." to include in what will be committed)
  #       project.netbeans
  nothing added to commit but untracked files present (use "git add" to track)
  $ git add .
  $ git commit -m "Added NetBeans project files"
  $ git push

In the above sequence, I first clone the project into a local directory,
outside of the netbeans_project directory.  I then copy the entire
contents of the netbeans_project directory into my local clone, and
delete the old version.  Changing into the project directory, I confirm
the presence of the netbeans project file with "git status".  I then add
and commit them as usual.

Note that "git add ." will add all files in the current folder and all
subfolders.  You may want to be more selective about which files you
add!  Look at the output of "git status" and add only those files which
you want in the repository.

Also be very careful with "rm -rf".  This will delete all files in the
directory specified and all subdirectories, without any kind of
confirmation dialogue to make sure it's ok.

> When I deleted all the content and cloned it again, it put all the contents 
> into a sub-folder. So I tried using fetch. When I fetched, it took a very 
> long time and looked like it was doing work (it was showing me some kind of 
> progress), but when it got all done the folder was empty. I tried this a 
> couple of times and then tried pull, which did the same thing. At one point 
> after a fetch I typed "git status" and got a long message saying all my 
> files were deleted. Finally after searching around for clues decided to 
> clone into a separate directory then copy and paste all the contents of 
> that directory back over to my project directory. 

When describing problems like these, it is always better to provide a
log of exactly the commands you typed and their output than to try and
describe it in English.  You can simply copy and paste the contents of
your command prompt window.

> I guess my question is, how do I get my files out of the repository and 
> into an existing folder on my computer? And why doesn't fetch or pull 
> actually fetch or pull any files down from the repository?

"git fetch" will fetch the contents of the remote repository into the
local repository (remember your local clone is a full repository!), but
will not merge those files with any of your local branches or check them
out into the working tree[2].  "git pull" performs a "git fetch",
followed by a "git merge" of the branch you're currently tracking into
your local branch[3].  To get an idea of what this means, run a "git
fetch" when you have upstream changes and then look at the output of the

  $ git log --graph --oneline --decorate --all

You should see a commit decorated with "master", and another commit
decorated with "origin/master" a few commits later (assuming default

A "git pull" will perform a merge, bringing the local "master" branch
in line with the remote "origin/master".

> Thanks,

I hope I've helped rather than muddying the water with this long and
terminology-laden email!  Understanding that your own clone is a full
repository (the fundamental property of a DVCS), that a repository is
simply a graph of commits, and that commands like "fetch" often modify
parts of that graph other than that which you're working on, is the key
to demystifying git, IMO.  Once you've grasped those concepts, it'll all
start to fall into place :-)



You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to