Re: [git-users] Re: Multiple clones of the same remote repo

2020-03-19 Thread David
I just wanted to let you know that your post here is still helping folks!

I gained a lot of good info from it, and it allowed me to understand pulls 
and fetches much more completely!

Thanks!


On Tuesday, September 3, 2013 at 8:22:28 AM UTC-4, Konstantin Khomoutov 
wrote:
>
> On Mon, 2 Sep 2013 21:43:26 -0700 (PDT) 
> Juha Aaltonen > wrote: 
>
> > I guess I described the problem. 
>
> I guess I explained the reason for `git fetch` reporting everything is 
> up-to-date and `git pull` complaining about conflicts. 
>
> > I don't seem to be able to update my working tree from the remote 
> > repo using Giteye. 
> > The pull complains about masses of conflicts (even if I know that not 
> > that much has changed) and 
> > the fetch just says the SW is the same (nothing to merge). 
> > 
> > Maybe the problem is in Giteye, not in the repo clones. It's hard to 
> > understand why the different results. 
> > (everything changed / nothing changed) 
>
> In your case, it seems, the root problem is that people are taught Git 
> by making them memorize several simple commands which should "just do 
> this", without explaining what actually happens.  So someone told you 
> "use git-pull to bring the changes from remote repos"; that someone 
> failed to explain in detail what `git pull` actually does, and why it 
> may legitimately fail. 
>
> So let me try to explain the situation in more detail... 
>
> When you clone a repository, Git: 
>
> 1) Creates or initalizes a local repo. 
>
> 2) In its configuration, creates a single "remote" named "origin". 
>
> 3) Fetches all the branches from the remote repository, creating 
>a single "remote branch" for each branch that repository has. 
>You can enumerate these branches by running `git branch -r`. 
>
> 4) Creates a single normal branch which tracks one of the created 
>remote branches -- matching that which is currently "main" 
>in the repository being cloned, this is "master" most of the time. 
>
> Recently I explained to someone here these concepts in detail, so 
> please refer to [1] for more info. 
>
> Now the `git fetch origin` (or just `git fetch` in your case) contacts 
> the repository pointed to by the remote named "origin" in the 
> configuration of your local clone and fetches all the branches from it 
> -- updating the matching *remote branches* for that repository, and 
> creating new, if needed.  The crucial thing to understand is that none 
> of your personal local branches is ever updated by this command. 
> Of course, if you call `git fetch` twice in a row, it's likely that the 
> first call brings some changes in and the second one reports that 
> everything is up-to-date, because the state of the remote repository 
> stored locally in the form of remote branches for it is the same as the 
> state of branches in that remote repository. 
>
> The usual course of action when you want to reconcile the changes 
> someone did to the branch of interest located in some remote repository 
> and your changes you did to a branch in your local repository is to 
>
> 1) Fetch from the remote repository to update its remote branches in 
>your local repository. 
>
> 2) Check out the necessary local branch. 
>
> 3) Inspect what changes the relevant remote branch has compared to your 
>branch, and in reverse. 
>
> For instance, if you have a local branch named "master" which tracks 
> the same named branch in a remote repository named "origin", you'd do: 
>
> git fetch origin 
> git checkout master 
> # What the remote "master" has our local "master" hasn't? 
> git log master..origin/master 
> # What changes our local "master" has which the remote "master" hasn't? 
> git log origin/master..master 
>
> Now we can merge: 
>
> git merge origin/master 
>
> This operation might rightfully result in conflicts if both sides 
> changed the same portions of the same files. 
>
>
> Now let's move to `git pull`.  It has much magic built in, and that's 
> why it really sucks to ever tell Git newcomers this command exists (but 
> everyone does this, unfortunately). 
>
> When you have a branch named "master" checked out and do `git pull`, 
> it goes like this: 
>
> 1) Reads the branch.master.remote configuration variable to learn which 
>remote this local branch named "master" "tracks". 
>
>In a typical setup: 
>
>$ git config --get branch.master.remote 
>origin 
>
>If you call `git pull ` this step is skipped and the 
>name of the remote is taken from the command line. 
>
> 2) Reads the branch.master.merge configuration variable to learn which 
>branch this local branch named "master" "tracks" in the remote 
>repository learned on step (1). 
>
>In a typical setup: 
>
>$ git config --get branch.master.merge 
>refs/heads/master 
>
>If you call `git pull  ` this step is skipped 
>and the name of the branch is taken from the command line. 
>
> 3) Fetches a branch which name was obtained on step (2) from the 
>

Re: [git-users] Re: Multiple clones of the same remote repo

2013-09-03 Thread Magnus Therning
On Mon, Sep 02, 2013 at 09:59:43PM -0700, Juha Aaltonen wrote:
 To put it more clearly:
 
 There are a couple of guys working with a code and there's a common
 repo on a server.
 
 I cloned the remote repo with both Giteye and SourceTree (two
 different clones).
 I edited the code cloned with SourceTree, committed the changes and
 pushed the changes back to the remote repo. Then some other people
 have made some changes in some parts of the program and I made
 changes in another part of the program in the Giteye-clone.
 
 Before committing I wanted to update the Giteye-clone, but pull
 shows that everything has changed and everything is in conflict
 whereas fetch shows that nothing has changed.
 
 I managed to do the changes using the SourceTree-repo - first
 pulling then manually merging from the Giteye-tree and then
 committing/pushing using the SourceTree.

I would strongly suggest you drop into a shell and test what git on
the command line says.  Many of the GUIs for git are great, but they
sometimes make it /very/ difficult to understand what the exact state
of a clone is.

/M

-- 
Magnus Therning  OpenPGP: 0xAB4DFBA4 
email: mag...@therning.org   jabber: mag...@therning.org
twitter: magthe   http://therning.org/magnus

Those who would give up Essential Liberty to purchase a little
Temporary Safety, deserve neither Liberty nor Safety
 -- Benjamin Franklin, Historical Review of Pennsylvania, 1759


pgpuQmwGffhuT.pgp
Description: PGP signature


[git-users] Re: Multiple clones of the same remote repo

2013-09-03 Thread Juha Aaltonen

Truckload of thanks for the explanation.
It must have taken a lot of iron wire to bend it for me. :-)


-- 
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.


[git-users] Re: Multiple clones of the same remote repo

2013-09-02 Thread Juha Aaltonen
I guess I described the problem.
I don't seem to be able to update my working tree from the remote repo 
using Giteye.
The pull complains about masses of conflicts (even if I know that not that 
much has changed) and
the fetch just says the SW is the same (nothing to merge).

Maybe the problem is in Giteye, not in the repo clones. It's hard to 
understand why the different results.
(everything changed / nothing changed)


maanantai, 2. syyskuuta 2013 16.36.08 UTC+3 Juha Aaltonen kirjoitti:

 Does git get confused if I have multiple clones of the same remote repo?
 What I mean is that in one clone I've made commits (and pushes), and the 
 other clone hasn't seen them.

 I seem to have some problems pulling to the clone that hasn't been used 
 for commits/pushes.
 On the other hand, the pull reports a lots of conflicts, but fetch says 
 it's up todate.

 I've been using Windows, and trying out two clients: SourdeTree for the 
 other clone (with commits/pushes) and Giteye with the
 clone for the pull/fetch problems.

 I just wondered if the same username with clones both having and missing 
 commits could confuse Git.



-- 
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.


[git-users] Re: Multiple clones of the same remote repo

2013-09-02 Thread Juha Aaltonen
To put it more clearly:

There are a couple of guys working with a code and there's a common repo on 
a server.

I cloned the remote repo with both Giteye and SourceTree (two different 
clones).
I edited the code cloned with SourceTree, committed the changes and pushed 
the changes back to the
remote repo. Then some other people have made some changes in some parts of 
the program and I
made changes in another part of the program in the Giteye-clone.

Before committing I wanted to update the Giteye-clone, but pull shows that 
everything has changed and
everything is in conflict whereas fetch shows that nothing has changed.

I managed to do the changes using the SourceTree-repo - first pulling then 
manually merging from the
Giteye-tree and then committing/pushing using the SourceTree.



-- 
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.