GIT help

Hi All,

I have my own development area on my laptop, and I of course use git
extensively. Then once I am done with required changes I do ‘git push
origin master’.

But I always have to do ‘git reset --hard’ to make my changes active. I
know there must be a better way. Just to clarify, I never ever change
anything on the production system, and no logs are in the repository.

What is a better way to do a merge. On the server, when I do git
status, it
tells me that certain files have changed and are waiting to be
committed,
exact same files as I just pushed to the server.

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.

Best regards,

Trausti

On Mon, Oct 26, 2009 at 10:36 AM, Trausti Thor J.
[email protected] wrote:

exact same files as I just pushed to the server.
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.

Best regards,

I’m sorry, but I think this has nothing to do with Ruby and/or Rails.
you should have, AT THE VERY LEAST, tagged it as OT.
Resetting things to make changes active is not a normal practice with
git. Maybe something is wrong with you repository, you shoud get the
git docs and try to repair it, or maybe re-init it, but for sure you
should get any good git documentation. Man pages should be enough for
this, or you can find some book, there’s a few out there.

Cheers.


Leonardo M…
There’s no place like ~

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
shared repository.

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs