Can't pull from one bare git repo to another

Here’s my setup:

I’ve got one a ‘master’ git repository with a hosted service. All code must end up on here. Call this ‘master’.

  • Can you clone GitLab snippets?
  • Best way to run build scripts before deployment of web app?
  • Using revert to state before last git pull --rebase state
  • Is a more targeted recovery from git bisect mistakes possible?
  • cap deploy suddenly says Authentication Failed
  • Why is the “Load putty key” field in TortoiseGit disabled?
  • Because of permissions (wanting to limit the number of SSH keys used for the hosted service), and because I initially started coding pointing to another repo, I’ve got a bare repository on a VPS. Call this ‘VPS’.

    I work locally on development, push to VPS, log into VPS periodically and push to master.

    The problem I’ve got is that I deployed my web site by cloning from master. I made some changes and pushed them back to master. So now I need to execute git pull on VPS so it’ll get the latest code from master. Unfortunately when I try this, git tells me I can’t do this with a bare repository. To make things more complicated I didn’t realise this, so I’ve pushed some new code from development to VPS, so VPS is missing some commits part way through the log (i.e. not the most recent commits made across all the code).

    How can I fix this, and what would be a good way of setting things up so I can push and pull from VPS?

    Thanks

    — edit —

    OK, so I need to be able to merge the last 3 commits from VPS into a new clone of master. How can I do this, and how should I configure the repositories in git?

  • How to 'git status' only working tree changes in git?
  • Merge branches without checking out branch
  • Is there a tool that automatically saves incremental changes to files while coding?
  • How to get files from a commit, to a folder outside from my repository?
  • How to restrict user access to a particular Git repository in VSTS?
  • Gitting with a team
  • 3 Solutions collect form web for “Can't pull from one bare git repo to another”

    If you have to do a merge (or cherrypick, which could involve merge), you need to do it on a repository that is not bare.

    You could do it on your local development machine. Make both master and VPS remotes, fetch from both, and merge them both into you local development master branch. Then push this branch to VPS, then push it from VPS to master. Both those pushes should be fast-forward and work (provided no one has pushed any changes to VPS or master in the mean time, in that case merge again).

    Another alternative is to convert VPS from bare to normal and do the merge there. You can do this by recreating VPS (clone from master without the –bare switch). If you recreate it in the same place, the remote settings for local development will still point to it.

    git pull is the equivalent of git fetch + git merge.

    Merging obviously requires a working copy (in order to be able to resolve conflicts, if any).

    Since you don’t actually want to merge anything when moving stuff between two bare repositories (merging should be done in your own clone’s working copy), and you just want to get the new value of a branch, you should just invoke git fetch directly.

    I don’t understand your problem. You have access to both VPS and master. You can push and pull from/to both. You can just pull from both, merge those changes and then push up the result to both.

    Git Baby is a git and github fan, let's start git clone.