0

I have the following problem with my ZF2 project.

Before I ask my question, I would like to inform you that I'm not familiar with Git and used to work with Subversion for years. For this project I want to use Git, because ZF2 is using this and after some reading the suggestion is to prefer Git over Subversion.

The project is based on Zend Framework 2. ZF2 uses a git repository. I don't remember exactly, but when I started the project I just "cloned" the zf2 skeleton application into my webfolder and then I started writing my own modules.

My actual question is: How can I use my own (private) git repository (hosted on bitbucket.org) without interfering with the git repo zf2 uses?

I think I could follow one of these approaches:

  1. I just commit everything (including all the zf2 files) to my own repository. Every once in a while I update zf2 to a newer version. Obviously the files then have changed, and I commit this to my own repository. If I want to do this, I think I should delete the .git folder in the root directory of the project.

  2. I commit only the three folders that actually get changed by me, and I ignore the rest (using .gitignore?). So my commits would only contain my own modules, configuration and public files. The zf2 files are not even present in my repository.

Somehow both of these approaches seem weird to me and it seems to me that I am thinking to much in a Subversion way.

My questions are:

  • Is there anyone who can tell me what would be the best way to do this?
  • What is the best way to keep zf2 up to date if I have the project in my own repository?

I found this thread on stackoverflow which related with my problem. Any help would be appreciated. This is my first question on stackoverflow.

Community
  • 1
  • 1

1 Answers1

0

If you started with the ZF2 Skeleton Application, then yes, you should delete the .git folder that it comes with, then run git init . to initialise a new git project. Then you can make commits as normal.

If you are using Composer, I'd also suggest editing the .gitignore file to add vendor/ and remove composer.lock (I'm not sure why the skeleton app is setup in this way). That way you're not filling up your Git repository with ZF2 code, and anyone else who checks out your project can easily install the same dependencies you have.

Tim Fountain
  • 33,093
  • 5
  • 41
  • 69
  • Hey Tim, Thanks for your reply. I still think git is interfering with ZF somehow, because when i do: git push -u origin master (this should be my initial commit, right?) the response is: "fatal: 'origin' does not appear to be a git repository" and git remote -v gives: "composer.json composer.lock (fetch) composer.json composer.lock (push)" – Johann Sebastian Berg Nov 22 '13 at 10:10
  • Have you added a remote for your repository (with `git remote add`)? You might want to take a look at `.git/config` and see if anything looks awry (perhaps compare with another working project). – Tim Fountain Nov 22 '13 at 10:40
  • Thanks, I think i'm a bit closer to a solution now. I removed the remote section in the git config file (there was a remote section for composer, i should delete this right?) and added my own remote section. However, when i do "git push -u origin master", i get the following error: "Updates were rejected because the tip of your current branch is behind its remote counterpart. Merge the remote changes (e.g. 'git pull') before pushing again." – Johann Sebastian Berg Nov 22 '13 at 11:03