On Fri, 17 Jan 2014 16:00:24 +0200
Nikos Balkanas <nbalka...@gmail.com> wrote:

> > > I need to check out a revision from a repository, that supports
> > > only git. I don't know much about git, but I am used to svn.
> > > It seems that git first needs s clone before doing anything. And
> > > that clone would be the current version - the wrong one in my
> > > case. After that I do:
> > > git checkout <rev-number>
> > >
> > > I get informed that Head now is pointing the rev-number. I need to
> > > download that revision, and also overwite anything from the
> > > current version, while erasing any extra files or dirs.
> > >
> > > I have tried everything i could find, fetch --all, clean -fd etc.,
> > > but I always ene up with the initial, wrong version.
> > >
> > > What should I do?
> >
> > After you cloned a repository, like with
> >
> >   git clone repo_url target_dir
> >
> > The target directory will contain a subdirectory named ".git"
> > holding the Git object and configuration store (that's what
> > constitutes the local repository), and the directory itself is
> > turned into the so-called "work tree" in Git's terms -- by default
> > `git clone` checks out the tip commit of the default branch of the
> > repository it cloned.
> >
> > Ignoring that bit for the moment, to bring the work tree into the
> > state of the revision you need, you do
> >
> >   cd target_dir
> >   git checkout name_of_revision
> >
> > That "name_of_revision" is a tricky part: it might be the SHA-1
> > name of a particular commit or the name of a branch (in which case
> > it will mean the tip commit at that branch's history) or the name
> > of a tag (in which case it will mean the commit tag points to).  It
> > also might be a special expression but let's pretend it's not your
> > case.
> >
> > Running out `git checkout` *does* remove files and directories from
> > the work tree if and only if they are currently tracked -- that is,
> > present in the commit the work tree's contents is based on.
> > What this means for you?  If HEAD includes (tracks) a file "foo"
> > and a directory "bar", they will be in your work tree unless you've
> > deleted them by hand.  Should now you check out a commit which does
> > not include the file "foo" and the directory "bar", Git will remove
> > them *unless* you have local modifications in the file "foo" or in
> > one of the files under "bar" which are tracked by HEAD.
> >
> > Let's recap: what you do *should* work; without any `git clean` etc.
> > So either you're doing something wrong or your premises are wrong.
> > Please provide more context for us: what's the name of the revision
> > you need, is it a tag or a branch (can be known by correlating this
> > name with what `git branch -a` and `git tag` output) or the SHA-1
> > name of a commit.  What exactly command do you run for checking out?
> > What's the output of running `git status` afterwards?
> >
> Thanks for the fast reply. I am breaking my head over it since
> yesterday :-( Here is the output you asked (State is after clone and
> checkout revision):
> 1) Revision:
> 
> $ git describe --always --abbrev=8 --long
> e9a82163
> 
> $git branch -a
> * (no branch)
> master
[...]
> $git tag
> 3.3git
[...]

OK, so you have been told to check out a revision by the SHA-1 name of
its commit, and so you did.

Also please answer the most important question: why do you think
something's wrong with your checkout?
And can we please see the result of `git status`?  I'm asking this
because this might shed some light on the issue -- say, it'll list many
modified or missing or untracked files.
May be you'll be able to figure what's wrong just by looking at that
output.

Note that there's still a chance of you have been told to check out a
wrong revision.

P.S.
Please don't top-post -- this breaks the discussion flow, which sucks.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to