0

I have my webapp on a server I would like to maintain from my local machine version controlled by Git.

I want to copy and start tracking what is on the server now to local.

So what I did is

on the server:

git --bare init app.git

and local

git clone ssh://me@server/path_to_app.git 'app'

And

git pull

in order to get the server snapshot on the local machine.

this is the error I would like to resolve:

Your configuration specifies to merge with the ref 'master'
from the remote, but no such ref was fetched.   

local branch = master

remote origin

I would like to make a first snapshot of the server. For this is empty of coarse. Can I run origin add -A and commit? Or something like that? And then git pull?

Or is my line of thinking not correct?

Webconstructor
  • 525
  • 2
  • 6
  • 15

3 Answers3

0

The problem is that you created a new bare repository, and it has no content. Just make sure that there's actually a branch called master on the remote with some commits on it and all the warnings should go away.

Carl Norum
  • 219,201
  • 40
  • 422
  • 469
0

You need to create the remote master branch to be able to pull from it. You can do this from your local checkout by doing:

git commit --allow-empty --allow-empty-message -m ''
git push -u origin master

Obviously, the first commit you push in doesn't have to be empty, you can just do it when you have something useful to add. There just has to be a commit to push.

(The reason is that the new clone doesn't really have a master branch either until you commit something. .git/HEAD points to the non-existent ref: refs/heads/master. Your first commit will create this if it doesn't exist.)

millimoose
  • 39,073
  • 9
  • 82
  • 134
  • Sorry this doesn't work: `git commit --allow-empty -m 'empty ` `master' [master (root-commit) b12ae2f] empty master` `git push origin master` `* [new branch] master -> master` `git pull ` `Already up to date.` So it does not include the files I allready have on the server. Is the only way to start locally? – Webconstructor Sep 25 '13 at 15:23
  • @user1762879 I'm confused, you never said you have files on the server - you just mentioned `git init --bare`. What files are supposed to be in the repo? – millimoose Sep 25 '13 at 17:34
  • Well my first sentence is _" I have my webapp on a server I would like to maintain from my local machine version controlled by Git. "_ So those webapp files are the files which are allready there and need to tracked and added to the first origin. Can this be done? Indeed all examples start with an empty file on the server. I would like to track and develop further an existing project. – Webconstructor Sep 25 '13 at 18:45
  • @user1762879 As far as I know, you can't meaningfully create a **bare** repo over existing sources. A bare repo, by definition, doesn't contain a working tree. I'd say you'll have to push existing sources into it. (Or create a regular git repo over your existing sources, commit, and then make a bare clone.) – millimoose Sep 25 '13 at 20:35
  • I get what you're saying. I was just wondering if it's possible. Thx thusfar. – Webconstructor Sep 26 '13 at 08:29
0

this

http://danbarber.me/using-git-for-deployment/

tutorial showed me the exact right way step by step

Webconstructor
  • 525
  • 2
  • 6
  • 15