2

I've received a bare git repository to work on - let's call it bare.git.

I've saved it into D:/workspace/bare.git and cloned it

$git clone bare.git bare

Everything worked normally untill I wanted to push my changes. I've received the following git error

$git push
error: failed to push some refs to 'D:/workspace/bare.git'

$git push origin master
error: failed to push some refs to 'D:/workspace/bare.git'

From my perspective everything is set properly but I still cannot figure out why I cannot push anything.

$git remote show origin
remote origin
Fetch URL: D:/workspace/bare.git
Push  URL: D:/workspace/bare.git
HEAD branch: master
Remote branch:
    master tracked
Local branch configured for 'git pull':
    master merges with remote master
Local ref configured for 'git push':
    master pushes to master (up to date)

This is my .git/config

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
[remote "origin"]
    url = D:/workspace/bare.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

And yes - there are some commits already in the master branch of the bare repository.

Any ideas?

W17chM4n
  • 21
  • 2

1 Answers1

2

It can fail to push when your local changes(commit history) interferes with the history of server history. For e.g., when you cloned the repo, the history looked like A-->B-->C and then you made a change that made commit history look like: A-->B-->C-->D. In the mean time, if someone pushed to server, with commit E, the history on server would look like A-->B-->C-->D-->E

In such scenario, you would not be allowed to push.

You can

  1. pull from server and then try to push

  2. make a force push - not recommended, because it will alter the server commit history.

prabodhprakash
  • 3,568
  • 22
  • 42
  • Yeah I've thought about it but it isn't the case for me. I've got this bare repo through email and it's not being shared with anybody. I'm definitly not rearranging the order of the commits. – W17chM4n Sep 26 '16 at 17:57
  • While I trust you on this, would it be possible for you to check this once to make this it very sure. Can you print commit-id of latest commit of server and local? Comment, if you need help in getting commit id. – prabodhprakash Sep 26 '16 at 17:59
  • I can give you the commit-id but as I've stated above - it's not the problem. I've got a bare repository which is not connected to anything. I should be able to push to it without any problems. – W17chM4n Sep 26 '16 at 18:08
  • is it a git init on server or git init --bare on server. That can make some difference. – prabodhprakash Sep 26 '16 at 18:16
  • this I don't know. I've just received bare.git and that's it. – W17chM4n Sep 26 '16 at 18:24