Re: [git-users] Git branchs, broken drive & remote repositories

2011-08-25 Thread Konstantin Khomoutov
On Thu, 25 Aug 2011 07:37:45 -0700 (PDT)
GunsNRails  wrote:

> Two days ago my mbp just died and I need to erase and reinstall.
> I use git for some Rails projects. As far as I remember all the
> projects where pushed to remote repositories in Heroku so I think the
> changes are there safe. One of the projects has 2 branches and each
> branch was pushed to a different repository.
> 
> Also just in case I had access to the broken drive and managed to copy
> the projects to a USB stick.
> 
> My questions:
> 
> 1- Do the copies I have on the USB contain all the stuff, including
> branches? My guess is they do but just want to double check before
> erasing.
Depends on how do you define "copy".
If you copied a project directory including the ".git" directory
contained in it, and you had no funky configuration involving
relocation of the object store, the answer is yes.

> 2- In any case I guess that cloning from the remote repositories would
> restore my local system as it was. But regarding the one that has 2
> branches would the clone from one remote repository contain the
> details about the other branch? My guess is yes again.
Your guess is wrong: in Git, branches are somewhat orthogonal to the
content they help to track.  A branch is merely a moving pointer to a
commit: when you push a branch to a remote repo, in that repo such a
pointer (a special file in the Git data directory, actually) is created
and is set to point to the commit which has been pushed into that
branch.  Commit objects themselves do not hold any information related
to the branch they are on (or were on in the past) nor do branches keep
any information about other branches.

To recap: a branch physically is just a file under the ".git" directory
of your local repository, it's not pushed anywhere.  Also a tracking
branch has a special entry in your .git/config file which specifies how
it is to be synchronised with the branch it tracks.

But in this particular case you could just clone the first repo (no
matter which one first) then add another remote for the other repo and
fetch the missing branch from it.  Provided you had no local
unpublished (not pushed anywhere) branches that would restore the
pre-fail state of your local repository.

-- 
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 git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.



[git-users] Git branchs, broken drive & remote repositories

2011-08-25 Thread GunsNRails
Hi,

Two days ago my mbp just died and I need to erase and reinstall.
I use git for some Rails projects. As far as I remember all the
projects where pushed to remote repositories in Heroku so I think the
changes are there safe. One of the projects has 2 branches and each
branch was pushed to a different repository.

Also just in case I had access to the broken drive and managed to copy
the projects to a USB stick.

My questions:

1- Do the copies I have on the USB contain all the stuff, including
branches? My guess is they do but just want to double check before
erasing.

2- In any case I guess that cloning from the remote repositories would
restore my local system as it was. But regarding the one that has 2
branches would the clone from one remote repository contain the
details about the other branch? My guess is yes again.

Could someone confirm?

Thanks.

-- 
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 git-users@googlegroups.com.
To unsubscribe from this group, send email to 
git-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/git-users?hl=en.