Skip to contentSkip to conversation

Problems pushing???

DISCUSSION pbGit 3 participants 8 messages Jun 15, 2016

lore
Share & tools
lore

pbGit

author
#0 lore raw

Hi,
I have installed git locally to my machine. It is running mac os lion.
This is intended to be the remote machine too. I have followed, what I think is the correct way to do this, using
http://www.petermac.com/setup-git-local-and-remote-repositories/ this . All seemed to be ok until I tried to push. When I try the following command.

git push --all --repo=<project>

I get the following output

Counting objects: 12, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (12/12), 5.23 KiB, done.
Total 12 (delta 1), reused 0 (delta 0)
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.

Hope someone can help with this because I have spent a bit of time trying to solve this and still stuck!!!

Thanks for your time,
Paul

--
View this message in context: http://git.661346.n2.nabble.com/Problems-pushing-tp7562695.html
Sent from the git mailing list archive at Nabble.com.

#1 lore raw
Quoted 16 lines · pbGit

I have installed git locally to my machine. It is running mac os lion.
This is intended to be the remote machine too. I have followed, what I think is the correct way to do this, using
http://www.petermac.com/setup-git-local-and-remote-repositories/ this . All seemed to be ok until I tried to push. When I try the following command.

git push --all --repo=<project>

I get the following output

Counting objects: 12, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (12/12), 5.23 KiB, done.
Total 12 (delta 1), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master

[...]

Quoted 2 lines

Hope someone can help with this because I have spent a bit of time trying to solve this and still stuck!!!

Becasue pushing to a so-called "non-bare" repository (this is a "normal" repository, in which there is a work tree) either has no sense or requires extra steps to reconcile the results of pushing with the repository's work tree. Most probably you should reconsider your workflow.

Read [1] for an in-depth explanation.
Googling for "receive.denyCurrentBranch" will also provide you with a number of useful links (such as stackoverflow discussions).

1. http://sitaramc.github.com/concepts/bare.html

author
#3 lore raw

Hi Holger,
I think you were correct. I deleted my git init on the remote(Well,
locally on my machine...), did what you said I was able to push successfully. Can I check the files have been successfully transferred to correct location??? Just wanted a bit of confidence it has done what it should of. I guess I can simply clone this from another machine and test?

--
View this message in context: http://git.661346.n2.nabble.com/Problems-pushing-tp7562695p7562705.html
Sent from the git mailing list archive at Nabble.com.

author
#4 lore raw

Just tried starting again on my local machine because when I tried pushing, git said that it local was also set to bare init. When I looked this was the case. Silly me.

So I deleted on my local and added a single file and when I try pushing this I get the following:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'paul@localhost:/Users/paul/<prject>'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

When I try and pull I then get the following:
fatal: No remote repository specified. Please, specify either a URL or a remote name from which new revisions should be fetched.

I then addded my repo with the following command, but this is the wrong syntax!!!
git pull --repo=<project>

What the hell am I doing wrong???

--
View this message in context: http://git.661346.n2.nabble.com/Problems-pushing-tp7562695p7562707.html
Sent from the git mailing list archive at Nabble.com.

#5 lore raw

Am 08.07.2012 17:43, schrieb pbGit:

Quoted 17 lines

Just tried starting again on my local machine because when I tried pushing, git said that it local was also set to bare init. When I looked this was the case. Silly me.

So I deleted on my local and added a single file and when I try pushing this I get the following:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'paul@localhost:/Users/paul/<prject>'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

When I try and pull I then get the following:
fatal: No remote repository specified. Please, specify either a URL or a remote name from which new revisions should be fetched.

Quoted 5 lines

I then addded my repo with the following command, but this is the wrong syntax!!!
git pull --repo=<project>

What the hell am I doing wrong???

This is the moment where you have to begin reading man pages, i.e. "git fetch", "git help pull", "git help remote" "git help push" (read the examples as they show typical use cases) or preferably read about it in books like Pro Git (git-scm.com/book/) or tutorials.

For example the --repo parameter in "git push --repo=<project>" doesn't exactly do what you think it does. It only sets the default remote repo from "origin" to <project>. Normally you would just use "git push <project>". And the equivalent pull command would be "git pull <project>".

Naturally you can configure that git pull or git push will just do what you want, but for that you need to know what a refspec is and how to use "git remote".

Generally git pull and git push are not complementary. Neither in effect nor in parameters they take.

For example assume you have just cloned a remote repository. This will add configuration that connects both repositories and adds a default remote repo named origin and adds default refspecs

"git pull" without parameters will then fetch all remote branches into correpondingly named local remote tracking branches (under .git/refs/remotes/, do a git branch -a to list them too), but then only merge one of them with the branch you are in at the moment.

But "git push" will push *all* your local branches into branches of the same name on the remote repository.

Another difference: If you pull, the merge might fail because of merge conflicts and you have to manually merge conflicting files. If you push, this manual merge is not possible so usually only trivial merges called fast-forward-merges are allowed. That is what happened on your push

Something like "git remote add -m master origin <urlofyourrepo>" does the same configuration as a "git clone" would do and would allow you to just use "git pull" without parameters.

author
#6 lore raw

Thanks for all your help. Running through this a few more times and reading the net I managed it ; ) I tested it cloning from the command line and all seems good.

For developement I use eclipse with the eGit plugin. When I try cloning it
putting all the relevant info in it fails. I am sure this is due to the
ssh keys. I have set-up my keys accordingly. Tried using the ssh agent but with no success. I can see the agent is running and tested that and all seems good with that. The error get is

ssh://paul@localhost:22:
org.eclipse.jgit.transport.CredentialItem$StringType:Password:
ssh://paul@localhost:22:
org.eclipse.jgit.transport.CredentialItem$StringType:Password:

Hope you can help

--
View this message in context: http://git.661346.n2.nabble.com/Problems-pushing-tp7562695p7562762.html
Sent from the git mailing list archive at Nabble.com.

#7 lore raw
In reply to Holger Hellmuth
Quoted 4 lines · Holger Hellmuth
Quoted 1 line

http://www.petermac.com/setup-git-local-and-remote-repositories/ this . All

The recipe at this address seems to have a "--bare" parameter missing at the git init in step 7

The OP stated that «This is intended to be the remote machine too.» wich hints he wants to also receive changes to this repo from the outside.
Supposedly he should stick to pulls only.
Or set up a bare repo on the local machine and then clone it to its "working" repo using a plain path like /path/to/that/shared/repo.