Checking out a remote branch does not seem to work.

6 views
Skip to first unread message

allanbj...@gmail.com

unread,
Jan 28, 2009, 4:42:41 PM1/28/09
to msysGit
Hello,

We're looking into using GIT to manage our source code, and are
currently running some tests to see how well it will work in our
environment. (Working with version 1.6.1-preview20081227.)

I set up a repository for a project on a shared Windows volume,
cloned it to another Windows machine, branched made some edits, and
pushed it back into a new branch in the original repository just fine.

I now went to another Windows workstation, cloned the original
repository again, and wanted to work on the branch. But checking out
the remote branch doesn't update my files on disk. I can see the
branch history just fine, and it shows me the deltas, but nothing I do
will give me the branch files to actually edit, only the master files
in the original repository.

I've looked at several tutorials, including the one located at
http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html , and
have tried several different combinations of commands, but I can not
get the branch version of the files.

The commands I've used in the git shell.

git clone --no-hardlinks //path/to/our_main_repository
my_local_copy

Will error out if I don't include --no-hardlinks. (I've also tried
--local.)



git checkout --track -b myBranch origin/remoteBranch

It says it's tracking remoteBranch, and that I'm automatically
switched to myBranch.



edit a file, and see that it's still the version from the
master branch.



git pull origin remoteBranch

A suggestion from another tutorial.



edit a file, still the master branch version.



git remote add aNameForTheRemote //path/to/
our_main_repository
git fetch aNameForTheRemote

Another suggestion from another tutorial.


edit a file, still the master branch version.





Can someone point out what I'm missing? Why can't I create a local
copy of a remote branch?


--Allan

Johannes Schindelin

unread,
Jan 28, 2009, 6:09:46 PM1/28/09
to allanbj...@gmail.com, msysGit
Hi,

On Wed, 28 Jan 2009, allanbj...@gmail.com wrote:

> I set up a repository for a project on a shared Windows volume,
> cloned it to another Windows machine, branched made some edits, and
> pushed it back into a new branch in the original repository just fine.

Nope. It did not work just fine, because you pushed into a checked-out
branch.

For historical reasons, we allow that, but that does not mean that it
worked correctly. Basically, there is no sane way to allow pushing into a
checked-out branch.

You might want to redo the setup with a _bare_ repository that you clone
from and push into.

I am preparing a patch to make this pilot error easier to handle, but do
not hold your breath for it.

Ciao,
Dscho

allanbj...@gmail.com

unread,
Jan 29, 2009, 5:57:02 PM1/29/09
to msysGit
On Jan 28, 6:09 pm, Johannes Schindelin <Johannes.Schinde...@gmx.de>
wrote:
> Hi,
I see, and understand now after reading your message, I found this
discussion http://kerneltrap.org/mailarchive/git/2007/3/18/241553 ,
and understand the situation better. But it's not very intuitive, and
it seems like a lot of others think the same way, as I found several
tutorials/howtos (some very recent) where pushing into an origin
branch was how they collected their remote development.

And the one detailed example ( http://hans.fugal.net/blog/2008/11/10/git-push-is-worse-than-worthless
) of using a blank repository, like you suggested, seemed like so much
work for something that I was hoping would be very simple.

After playing around for a bit I found that I could, knowing the
remote branches on the developer machines, pull their changes into the
branch in the original repository. That seems much simpler for most of
our situations.

The only issue is when the branch in the original repository is
checked out, and someone clones it, they get the branch files, not the
master files. So, searching the web for more examples, and reading
the man page for git-pull, I came across an example that looked like
it would allow me to pull into a branch with out actually checking it
out. I.e.:

git pull //remoteWorkstation/path/to/repository
remote_branch:the_branch_I_want_to_pull_to

And the feedback the command gave me seemed like it was working
( hexnumber..hexnumber remote_branch ->
the_branch_I_want_to_pull_to ), but when I went to examine the files I
found that it actually applied the pull to the master and the branch I
was targeting.

I've been struggling with git revert/reset and other things I'm
finding in the various other tutorials, trying to revert to the
original master, but I'm now afraid my repository is completely messed
up. (Fortunately, this is a small test, and the production code base
is elsewhere.)

And I can't use the individual developer repositories as a source
for a clean copy, as switching back to master on them gives me
messages about how they are are several commits ahead, and the files
do not revert to the original master I'm trying to get to.

This is very frustrating, as it seems any mis-step will mess up the
repository, and the commands work in counter intuitive ways.

--Allan

Johannes Schindelin

unread,
Jan 29, 2009, 7:44:22 PM1/29/09
to allanbj...@gmail.com, msysGit
Hi,

On Thu, 29 Jan 2009, allanbj...@gmail.com wrote:

> I've been struggling with git revert/reset and other things I'm
> finding in the various other tutorials, trying to revert to the
> original master, but I'm now afraid my repository is completely messed
> up. (Fortunately, this is a small test, and the production code base
> is elsewhere.)

I am just a dumb non-native speaker, but "revert" rather sounds to me like
"undo", not like "forget". The latter sounds more like "reset", but then,
I have been exposed to Git for quite some time.

> This is very frustrating, as it seems any mis-step will mess up the
> repository, and the commands work in counter intuitive ways.

Give me a break! I said I am working on it, didn't I?

Ciao,
Dscho

allanbj...@gmail.com

unread,
Jan 30, 2009, 9:28:26 AM1/30/09
to msysGit


On Jan 29, 7:44 pm, Johannes Schindelin <Johannes.Schinde...@gmx.de>
wrote:
> Hi,
>
> On Thu, 29 Jan 2009, allanbjorkl...@gmail.com wrote:
> >   I've been struggling with git revert/reset and other things I'm
> > finding in the various other tutorials, trying to revert to the
> > original master, but I'm now afraid my repository is completely messed
> > up.  (Fortunately, this is a small test, and the production code base
> > is elsewhere.)
>
> I am just a dumb non-native speaker, but "revert" rather sounds to me like
> "undo", not like "forget".  The latter sounds more like "reset", but then,
> I have been exposed to Git for quite some time.
>

I figured out what I needed to do to recover, and it was pretty
simple once I saw it work, it just wasn't obvious from the all the
examples and documentation out there.


> >   This is very frustrating, as it seems any mis-step will mess up the
> > repository, and the commands work in counter intuitive ways.
>
> Give me a break!  I said I am working on it, didn't I?

Sorry, I didn't mean to sound like I was attacking you. I
appreciate that this work is being done.

>
> Ciao,
> Dscho

--Allan
Reply all
Reply to author
Forward
0 new messages