On Mon, Oct 26, 2009 at 10:36 AM, Trausti Thor J.
[email protected] wrote:
What am I doing wrong here ?
In the future I would like to clone the repo to another computer and even
have more than 1 person working on the site.
It sounds to me like you’re misunderstanding the difference between push
and merge. If you want to use a git repository as a shared repository
then you should create a bare repository that does not contain a working
tree. Then each developer wanting to contribute makes a clone of that
This is essentially how the GitHub model works. The bare (shared)
repository exists on GitHub and everyone pushes their changes there. In
order to get changes pushed by other developers you fetch from the bare
repository and then merge those changes with your own branch. This is
essentially what pull does, which is fetch+merge.
It seems to be that you’re thinking the merging should happen during a
push, but that’s not true. The merge happens on pull. You’re having to
do git reset --hard because you’re trying to use the shared repository
for development/deployment as well. You shouldn’t be doing that. The
repository acting as the “central” repository should be bare and never
contain any local changes.
To create a bare repository use git init --bare. Then use that as your
“central” shared repository.
Add the bare repository as a remote for your existing repository:
git remote add origin <repository_url>
Push your master branch to the bare repository:
git push origin master
Then other developers can clone from the shared bare repository:
git clone <repository_url>
The other developer may make changes and push back to the shared
repository. Then you will pull from the shared repository to fetch and
merge his changes with yours.
Hope that helps.