threads / discuss / 30893

Urgent: Issue with GIT ...

Subject: Urgent: Issue with GIT ...

## tl;dr

10 messages between Jun 25, 2012 and Jun 26, 2012.

replies: 9people: 6as markdown or json

guruprasad· Jun 25, 2012, 11:49 UTC · lore
Hi,

I am Guruprasad from Bangalore, India working for HP. I am very much new to git and trying to establish a DVCS in my workstation. I am facing few problems please help me out. below i am giving my setup and the things i have done till now.

1) I have 2 Linux box (A and B). GIT installed in both of them.
2) I have one project in A and added to GIT repository.
3) Cloned A repository into B. Complete repository got cloned into B from A
along with all source code.
4) If I do some changes to files in A and commit, I am able to pull the
changes done and merge into B. (here i am not doing any push, just pull is
getting all updates)
5) If i do some changes to files in B, commit and push to remote branch, I
am unable to pull the changes done and merge into A. I have set
"receive.denycurrentbranch=ignore" in git config.

Can you please tel me where i am going wrong. Do I need to set anything in git config?

Once this test is done I need to implement patches over email by using JGIT in my application, please point me to some nice pointers so that i can implement it in Java. Please help in this as well.

Quick response is very much appreciated.

Regards, Guruprasad

-- View this message in context: http://git.661346.n2.nabble.com/Urgent-Issue-with-GIT-tp7562097.html Sent from the git mailing list archive at Nabble.com.

Konstantin Khomoutov· Jun 25, 2012, 12:07 UTC · re: guruprasad · lore

Re: Urgent: Issue with GIT ...

On Mon, 25 Jun 2012 04:49:40 -0700 (PDT) guruprasad <guruprasadkinI@gmail.com> wrote:

First, http://www.catb.org/~esr/faqs/smart-questions.html#urgent

[...]
Show 9 quoted lines
> 1) I have 2 Linux box (A and B). GIT installed in both of them.
> 2) I have one project in A and added to GIT repository.
> 3) Cloned A repository into B. Complete repository got cloned into B
> from A along with all source code.
> 4) If I do some changes to files in A and commit, I am able to pull
> the changes done and merge into B. (here i am not doing any push,
> just pull is getting all updates)
> 5) If i do some changes to files in B, commit and push to remote
> branch, I am unable to pull the changes done and merge into A.

What's missing, is the detailed description of how exactly you are "unable to pull the changes ...". That is, Git commands you run, the output they produce.

[...]

P.S. If you do cross post (you seem to have also posted the same question to the git-users ML), care to mention this in your mails.

guruprasad· Jun 25, 2012, 12:55 UTC · re: Konstantin Khomoutov · lore

Re: Urgent: Issue with GIT ...

Firstly, I apologize for staring subject with "Urgent" and thank you very much for your time and response.

As i told in my post earlier i am very much new to GIT, I was bit confused with the tests i went on. I am sorry for not describing it clearly in my last post.

1) Pull command is working fine with both the Linux box. Comp A can pull
updates from comp B, vise versa.
2) Push command is not working with both Linux box, command given below.
       git push A master/git push B master
3) When i tried above command first time got an error saying 
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare
repository
remote: error: is denied, because it will make the index and work tree
inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to
match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration
variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing
into
remote: error: its current branch; however, this is not recommended unless
you
remote: error: arranged to update its work tree to match what you pushed in
some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour,
set
remote: error: 'receive.denyCurrentBranch' configuration variable to
'refuse'.
To user@A:/home/user/workspace/TestProject/.git
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to
'user@A:/home/user/workspace/TestProject/.git'

so i added receive.denyCurrentBranch = ignore into git config and tried again. I dint get any error.

4) But, modified things in files did not get reflected. i tried to push from
A-->B and B-->A. both dint work.
5) Push command i tried after modifying file, staging and committing.
Please let me know if more information is required.

Yes, I posted the same question to the git-users ML. Sorry for not mentioning it in my post.

Thanks, Guruprasad

-- View this message in context: http://git.661346.n2.nabble.com/Urgent-Issue-with-GIT-tp7562097p7562100.html Sent from the git mailing list archive at Nabble.com.

jaseem abid· Jun 25, 2012, 13:05 UTC · re: guruprasad · lore

Re: Urgent: Issue with GIT ...

On Mon, Jun 25, 2012 at 6:25 PM, guruprasad <guruprasadkinI@gmail.com> wrote:
Show 53 quoted lines
> Firstly, I apologize for staring subject with "Urgent" and thank you very
> much for your time and response.
>
> As i told in my post earlier i am very much new to GIT, I was bit confused
> with the tests i went on. I am sorry for not describing it clearly in my
> last post.
>
> 1) Pull command is working fine with both the Linux box. Comp A can pull
> updates from comp B, vise versa.
>
> 2) Push command is not working with both Linux box, command given below.
>       git push A master/git push B master
>
> 3) When i tried above command first time got an error saying
> remote: error: refusing to update checked out branch: refs/heads/master
> remote: error: By default, updating the current branch in a non-bare
> repository
> remote: error: is denied, because it will make the index and work tree
> inconsistent
> remote: error: with what you pushed, and will require 'git reset --hard' to
> match
> remote: error: the work tree to HEAD.
> remote: error:
> remote: error: You can set 'receive.denyCurrentBranch' configuration
> variable to
> remote: error: 'ignore' or 'warn' in the remote repository to allow pushing
> into
> remote: error: its current branch; however, this is not recommended unless
> you
> remote: error: arranged to update its work tree to match what you pushed in
> some
> remote: error: other way.
> remote: error:
> remote: error: To squelch this message and still keep the default behaviour,
> set
> remote: error: 'receive.denyCurrentBranch' configuration variable to
> 'refuse'.
> To user@A:/home/user/workspace/TestProject/.git
>  ! [remote rejected] master -> master (branch is currently checked out)
> error: failed to push some refs to
> 'user@A:/home/user/workspace/TestProject/.git'
>
> so i added receive.denyCurrentBranch = ignore into git config and tried
> again. I dint get any error.
>
> 4) But, modified things in files did not get reflected. i tried to push from
> A-->B and B-->A. both dint work.
> 5) Push command i tried after modifying file, staging and committing.
>
> Please let me know if more information is required.
>
> Yes, I posted the same question to the git-users ML. Sorry for not
> mentioning it in my post.

If you really need a quick answer, hit the #git IRC channel on freenode. Its a zillion times faster than the mailing list.

-- 
Jaseem Abid
http://jaseemabid.github.com
Angus Hammond· Jun 25, 2012, 13:14 UTC · re: guruprasad · lore

Re: Urgent: Issue with GIT ...

On 25 June 2012 13:55, guruprasad <guruprasadkinI@gmail.com> wrote:
> remote: error: its current branch; however, this is not recommended unless
> you
> remote: error: arranged to update its work tree to match what you pushed in
> some
> 4) But, modified things in files did not get reflected. i tried to push from
> A-->B and B-->A. both dint work.
> 5) Push command i tried after modifying file, staging and committing.
>

I *THINK* the problem you're having is that the push to A updates the repository itself, but doesn't update the working directory unless you explicitly tell it to from machine A later on. This is why you got that horrible long error message when you did the git push, git was trying to stop you from creating a state where the repository and the working directory were different.

It seems like the solution would be to checkout master on machine A after you push, or even better, set up a bare repository somewhere on one of the systems and arrange for both of the repositories you work in to push/pull to that one.

Angus
Konstantin Khomoutov· Jun 25, 2012, 13:29 UTC · re: guruprasad · lore

Re: Urgent: Issue with GIT ...

On Mon, 25 Jun 2012 05:55:25 -0700 (PDT) guruprasad <guruprasadkinI@gmail.com> wrote:

[...]
Show 10 quoted lines
> 1) Pull command is working fine with both the Linux box. Comp A can
> pull updates from comp B, vise versa.
> 
> 2) Push command is not working with both Linux box, command given
> below. git push A master/git push B master
> 
> 3) When i tried above command first time got an error saying 
> remote: error: refusing to update checked out branch:
> refs/heads/master remote: error: By default, updating the current
> branch in a non-bare repository
[...]
Show 6 quoted lines
> so i added receive.denyCurrentBranch = ignore into git config and
> tried again. I dint get any error.
> 
> 4) But, modified things in files did not get reflected. i tried to
> push from A-->B and B-->A. both dint work.
> 5) Push command i tried after modifying file, staging and committing.

This is covered in the Git FAQ [1] -- see the question «Why won't I see changes in the remote repo after "git push"?»

Supposedly you should either stick to pulling or start using a "reference" repository (some prefer to call it "central") as already suggested in [2]. In your case, I don't see why you really need pushes so I'd stick to pulling.

1. https://git.wiki.kernel.org/index.php/GitFaq
2. http://groups.google.com/group/git-users/msg/5b545f06510c7e2d
Andy Hawkins· Jun 25, 2012, 13:02 UTC · re: guruprasad · lore

Re: Urgent: Issue with GIT ...

Hi,
In article <1340624980925-7562097.post@n2.nabble.com>,
           guruprasad<guruprasadkinI@gmail.com> wrote:
> 5) If i do some changes to files in B, commit and push to remote branch, I
> am unable to pull the changes done and merge into A. I have set
> "receive.denycurrentbranch=ignore" in git config.
Sounds like you're trying to push into a remote non-bare repository.
What I'd do is:
1. On 'A', create a bare repository.
2. Somewhere else on 'A', clone this repository. Work and push to the bare
in step 1 when necessary.
3. On 'B', also clone the repository from 1. Work and push to the bare when
necessary.

I don't think it's a good idea to push to a repository that has checked out files. I seem to remember this being mentioned in Pro Git.

Andy
Kevin· Jun 26, 2012, 06:08 UTC · re: Andy Hawkins · lore

Re: Urgent: Issue with GIT ...

The difference between bare and non-bare repositories is explained here [1].

In this setup, you should only pull from both repositories, not push to the other repository. If you want to push things, you should use a bare repository that both repositories can access and push to.

[1]: http://bare-vs-nonbare.gitrecipes.de/
On Mon, Jun 25, 2012 at 3:02 PM, Andy Hawkins <andy@gently.org.uk> wrote:
Show 31 quoted lines
>
> Hi,
>
> In article <1340624980925-7562097.post@n2.nabble.com>,
>           guruprasad<guruprasadkinI@gmail.com> wrote:
> > 5) If i do some changes to files in B, commit and push to remote branch,
> > I
> > am unable to pull the changes done and merge into A. I have set
> > "receive.denycurrentbranch=ignore" in git config.
>
> Sounds like you're trying to push into a remote non-bare repository.
>
> What I'd do is:
>
> 1. On 'A', create a bare repository.
> 2. Somewhere else on 'A', clone this repository. Work and push to the bare
> in step 1 when necessary.
> 3. On 'B', also clone the repository from 1. Work and push to the bare
> when
> necessary.
>
> I don't think it's a good idea to push to a repository that has checked
> out
> files. I seem to remember this being mentioned in Pro Git.
>
> Andy
>
> --
> 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
Andy Hawkins· Jun 26, 2012, 07:58 UTC · re: Kevin · lore

Re: Urgent: Issue with GIT ...

Hi,
In article <CAO54GHA=R1CyspFrC1n-JLVbm5eE+roXLBv6hFL5M1BHGAcVBA@mail.gmail.com>,
           Kevin<ikke@ikke.info> wrote:
> In this setup, you should only pull from both repositories, not push to the
> other repository. If you want to push things, you should use a bare repository
> that both repositories can access and push to.
Errr, isn't that what I said?
Andy
Kevin· Jun 26, 2012, 09:01 UTC · re: Andy Hawkins · lore

Re: Urgent: Issue with GIT ...

Yes, indeed. Read over your reply.
On Tue, Jun 26, 2012 at 9:58 AM, Andy Hawkins <andy@gently.org.uk> wrote:
Show 16 quoted lines
> Hi,
>
> In article <CAO54GHA=R1CyspFrC1n-JLVbm5eE+roXLBv6hFL5M1BHGAcVBA@mail.gmail.com>,
>           Kevin<ikke@ikke.info> wrote:
>> In this setup, you should only pull from both repositories, not push to the
>> other repository. If you want to push things, you should use a bare repository
>> that both repositories can access and push to.
>
> Errr, isn't that what I said?
>
> Andy
>
> --
> 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