W17chM4n
W17chM4n

Reputation: 21

Git - Can't push to local bare repo on Windows

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?

Upvotes: 2

Views: 1281

Answers (1)

prabodhprakash
prabodhprakash

Reputation: 3917

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.

Upvotes: 2

Related Questions