Reputation: 363
Here is the initial situation:
Then the remote server crashes.
I keep committing changes into my local repository but I cannot push them until we fix the server. In a day or so it becomes apparent that the server cannot be recovered due to a hardware problem, so the remote repository is lost. Meanwhile, I had already made several commits into my local repository.
Now I am trying to restore the repository on the server.
c:\repositories\myproject
git --git-dir=myproject config core.bare true
commandIt looks good, however, the problem now is that I have two branches in the bare repository, one is master
(server branch on the moment of crash), another is remote/origin
(the newer branch with my local commits).
So essentially I would like to push the outstanding commits to master and remove the remote/origin branch at all as it is not needed in the bare repository.
How do I do that?
Feel free to share a better way to accomplish such task.
Upvotes: 5
Views: 6904
Reputation: 75555
One way would be to re-initialize the remote repository completely cleanly and then do a push
from local.
On the server, in the directory where the bare repository should live, do
git init --bare
On the client (local repo), set the new origin if it has changed, and push to the server, and set up tracking again.
git remote set-url origin <Remote_URL>
git push origin master
git branch --set-upstream-to=origin/master master
Upvotes: 11