threads / discuss / 29252

Git beginner - Need help understanding

Subject: Git beginner - Need help understanding

## tl;dr

6 messages between Dec 27, 2011 and Dec 28, 2011.

replies: 5people: 3as markdown or json

chirin· Dec 27, 2011, 03:12 UTC · lore

I'm just beginning to use Git in my workplace, and (rather shamefully) have never heard of Git until now. While I pore over the stacks of documentations for beginners, could someone help me understand this issue I've been having?

Every time a colleague updates a file, I would not be able to pull due to merge conflicts - even though I have never made any changes to the repository. I'd try and then again, but it would still give the same merge conflict. The only way I could pull currently is to do a git commit (even without changes), and then git pull.

If this was SVN, I could simply resolve this with Update. What am I missing, and what should I be looking for?

Thanks in advance..

-- View this message in context: http://git.661346.n2.nabble.com/Git-beginner-Need-help-understanding-tp7129186p7129186.html Sent from the git mailing list archive at Nabble.com.

Dov Grobgeld· Dec 27, 2011, 06:34 UTC · lore

Re: Git beginner - Need help understanding

The best way of understanding and also of asking questions, is if you can reproduce the steps of exactly what you want and don't understand by a sequence of commands like so:

     # First create a bare repository
     mkdir R
     cd R
     git init --bare .
     # Clone it into A
     git clone R A
     # Clone it into B
     git clone R B
     # Now start doing changes for A and B, pulling and pushing into R
     cd A
     echo "Change #1" > hello.txt
     git add hello.txt
     git commit -m 'Commit #1'
     git push origin master
     # Get into B
     cd ../B
     git pull
     echo "Change #2" >> hello.txt
     git commit -a -m 'Commit #2'
     git push
     # Get into A and pull the changes done by B
     cd ../A
     git pull

In this sequence, which fulfills the scenario that you described, there are no conflicts. So I suggest that you try to change the command sequence to illustrate what you don't understand and ask again.

 Regards,
 Dov
 On Tue, Dec 27, 2011 at 05:12, chirin <takonatto@gmail.com> wrote:
Show 23 quoted lines
>
> I'm just beginning to use Git in my workplace, and (rather shamefully) have
> never heard of Git until now. While I pore over the stacks of documentations
> for beginners, could someone help me understand this issue I've been having?
>
> Every time a colleague updates a file, I would not be able to pull due to
> merge conflicts - even though I have never made any changes to the
> repository. I'd try  and then  again, but it would still give the same merge
> conflict. The only way I could pull currently is to do a git commit (even
> without changes), and then git pull.
>
> If this was SVN, I could simply resolve this with Update. What am I missing,
> and what should I be looking for?
>
> Thanks in advance..
>
> --
> View this message in context: http://git.661346.n2.nabble.com/Git-beginner-Need-help-understanding-tp7129186p7129186.html
> Sent from the git mailing list archive at Nabble.com.
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
chirin· Dec 27, 2011, 07:02 UTC · re: Dov Grobgeld · lore

Re: Git beginner - Need help understanding

From what I understand, your scenario is exactly what I expect. Which is why when I asked around my colleagues, no one was able to explain why I'm having this issue.

As per your scenario:
    # A changes hello.txt
    # Going into B (who has not done anything to hello.txt)
    git pull --> merge conflict on hello.txt
    git commit
    git pull --> OK

Would going through Gerrit have anything to do with it? I've compared git config -l with the others but they are the same (aside from remote.origin.url which has our own gerrit userid).

Dov Grobgeld wrote
Show 42 quoted lines
> 
> The best way of understanding and also of asking questions, is if you
> can reproduce the steps of exactly what you want and don't understand
> by a sequence of commands like so:
> 
>      # First create a bare repository
>      mkdir R
>      cd R
>      git init --bare .
> 
>      # Clone it into A
>      git clone R A
> 
>      # Clone it into B
>      git clone R B
> 
>      # Now start doing changes for A and B, pulling and pushing into R
>      cd A
>      echo "Change #1" > hello.txt
>      git add hello.txt
>      git commit -m 'Commit #1'
>      git push origin master
> 
>      # Get into B
>      cd ../B
>      git pull
>      echo "Change #2" >> hello.txt
>      git commit -a -m 'Commit #2'
>      git push
> 
>      # Get into A and pull the changes done by B
>      cd ../A
>      git pull
> 
> In this sequence, which fulfills the scenario that you described,
> there are no conflicts. So I suggest that you try to change the
> command sequence to illustrate what you don't understand and ask
> again.
> 
>  Regards,
>  Dov
> 

-- View this message in context: http://git.661346.n2.nabble.com/Git-beginner-Need-help-understanding-tp7129186p7129429.html Sent from the git mailing list archive at Nabble.com.

Junio C Hamano· Dec 27, 2011, 19:50 UTC · re: chirin · lore

Re: Git beginner - Need help understanding

chirin <takonatto@gmail.com> writes:
Show 13 quoted lines
> From what I understand, your scenario is exactly what I expect. Which is why
> when I asked around my colleagues, no one was able to explain why I'm having
> this issue.
>
> As per your scenario:
>
>     # A changes hello.txt
>
>     # Going into B (who has not done anything to hello.txt)
>     git pull --> merge conflict on hello.txt
>
>     git commit
>     git pull --> OK

This is quite different from what Dov showed as "the right way to report". Dob's recipe begins from absolutely empty state and creates three repositories involved with exact sequence and anybody can reproduce how it is supposed to work (or break). It was written in such a way that you can try to follow the sequence to see if you see a behaviour that is different from Dob expects (in which case your machine, filesystem or the Git binary you installed might be the culprit). Have you tried it?

Compared to that, your version above does not say anything about what the state of A, B and the repository A and B interact with were in before the problem started, so even if Dob wanted to help you by trying to reproduce your situation, there is not enough information to do so.

>> In this sequence, which fulfills the scenario that you described,
>> there are no conflicts. So I suggest that you try to change the
>> command sequence to illustrate what you don't understand and ask
>> again.
Exactly.
chirin· Dec 28, 2011, 01:38 UTC · re: Junio C Hamano · lore

Re: Git beginner - Need help understanding

The problem was solved by using another Gerrit ID for remote.origin.url in the config. I remain confused with Git.

Junio C Hamano wrote
Show 6 quoted lines
> 
> Compared to that, your version above does not say anything about what the
> state of A, B and the repository A and B interact with were in before the
> problem started, so even if Dob wanted to help you by trying to reproduce
> your situation, there is not enough information to do so.
> 

My apologies on being vague.. I'm here for learning purpose instead of get-someone-to-help-me-solve purpose. :P I'm really keen on learning what to look for, where to start looking to understand Git.

I'm having difficulties providing information that I do not yet know how to, as I'm still at the stage where I'm studying simple terminologies like origin, master, etc. and I tend to confuse myself more by comparing it to SVN.

What should I know about the 'states of A, B and the repository A and B interact with'?

-- View this message in context: http://git.661346.n2.nabble.com/Git-beginner-Need-help-understanding-tp7129186p7131536.html Sent from the git mailing list archive at Nabble.com.

Dov Grobgeld· Dec 28, 2011, 08:05 UTC · re: chirin · lore

Re: Git beginner - Need help understanding

I'm glad to hear that your problem was solved.
On Wed, Dec 28, 2011 at 03:38, chirin <takonatto@gmail.com> wrote:
> [stuff deleted]
> What should I know about the 'states of A, B and the repository A and B
> interact with'?

The state of a repository are most easily described by the sequence of commands done to it from its creation. The best way of learning and solving problems is trying to reproduce them with the minimum amount of steps. I.e. even if you are using a GUI tool for your convenience, you should be familiar with the command line tools, since that is the best way of conveying what you have done. My motto is: "Don't describe in human language what you have done, but show me the exact commands!". And there is no language better for such than the exact command line.

Regards, Dov

Show 8 quoted lines
>
> --
> View this message in context: http://git.661346.n2.nabble.com/Git-beginner-Need-help-understanding-tp7129186p7131536.html
> Sent from the git mailing list archive at Nabble.com.
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

← back to recent threads