skaz
skaz

Reputation: 22580

Sync Git Up To Server

My git client is behind my git server by a couple revisions and a git push doesn't seem to work because I did something quirky:

I had a git server on a machine whose harddrive crashed. Luckily, I had a backup although the backup was a couple of months old. I then made a new server and placed the backup git files up on the server.

In the time between the crash, I had made changes to files and committed them to the server. I have, for example, 1.4.8.30 locally, but only 1.4.8.26 on the server. When I try to git push the changes to the master branch on the server, it thinks everything is up-to-date, even though I can see the server is behind.

How can I get these files up to the server? I am scared I am going to lose revisions, or that these two are not correctly synced now. Thanks!

Upvotes: 1

Views: 50

Answers (1)

Urban
Urban

Reputation: 71

With Git, you have the complete repository locally (in .git directory).

Therefore a "restore" procedure should be:

  • Create a new bare Git repo (on the server)

git init --bare new-one.git

  • change origin (on the client)

    git remote rm origin

    git remote add origin path-to-new-one.git

  • Push your local data to repo

    git push --all

Note: This is gets more complicated if there are more than one users with different local commits. Hopefully, you do not need that ;)

Upvotes: 2

Related Questions